我有一个标签栏应用程序。这是我的代码
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[application setStatusBarHidden:YES animated:NO];
[self showSplashView];
}
- (void)showSplashView {
//If i don't use black view it displays white screen thats look so bad...
UIView* blackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
blackView.backgroundColor = [UIColor blackColor];
[window addSubview:blackView]; // sends [blackView retain]
[blackView release];
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:@"MyImage.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
[UIView beginAnimations:nil context:nil ];
[UIView setAnimationDelay:5.0];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:) ];
splashView.alpha = 0.0;
splashView.frame = CGRectMake(-60, -60, 440, 600);
[UIView commitAnimations];
}
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
UIView* blackView = [[window subviews] objectAtIndex:0];
[blackView removeFromSuperview];
[splashView removeFromSuperview];
[splashView release];
[window addSubview:tabBarController.view];
[window makeKeyWindow];
}
所以我的问题是当我的应用程序首先启动时它显示黑屏,几秒钟后它显示我的启动图像。当启动屏幕动画再次完成时,它显示黑屏,几秒钟后它显示我的视图控制器。我不知道为什么会发生。我希望我的问题很清楚。谢谢 编辑 我的预期行为是应用程序启动后它应该显示我的初始屏幕而不是黑屏,并且一旦启动动画完成它应该显示我的第一个视图控制器(这是第一个标签栏中的表格视图控制器)..
编辑 2: 这段代码是否很耗时 [window addSubview:tabBarController.view]; 我如何在启动画面运行时在后台执行此过程。