我想在啓動畫面上顯示UIActivityIndicatorView。 我只是在AppDelegate上通過splashview創建splashView和activityindicator。在splashscreen中的uiActivityindicatorView創建內存泄漏問題?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//[NSThread sleepForTimeInterval:3];
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
splashView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
UIImage *splashImage = [UIImage imageNamed:@"Splashimage.png"];
splashImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashImageView.image = splashImage;
[splashView addSubview:splashImageView];
progressIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(145,440,30,30)];
progressIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
[progressIndicator startAnimating];
[splashView addSubview:progressIndicator];
[self.window addSubview:splashView];
[NSThread detachNewThreadSelector:@selector(getInitialData:)
toTarget:self withObject:nil];
[self.window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
return YES;
}
- (void)getInitialData:(id)obj {
[NSThread sleepForTimeInterval:3.0];
[splashView removeFromSuperview];
[window addSubview:viewController.view];
}
它工作正常,除了內存泄漏。 我在控制檯中收到消息,自動釋放沒有到位的地方 - 只是漏水。 我做錯了什麼? 任何幫助將不勝感激。
因爲我M狀加載從網頁圖像的UITableView,我想閃屏上顯示indicatorview因此將clearify的東西被加載。 –
ahhh,這是非常討厭的方式,所以如果你要在你的tableview中加載圖像,那麼你爲什麼要在應用程序啓動時顯示活動指示器。用戶可能會感到困惑,該應用程序沒有啓動或出現問題。你應該在tableview上顯示活動指示器。如果數據相同,您可以使用緩存。 –
非常感謝Praveen-K的建議。 –