【发布时间】:2011-02-22 10:53:33
【问题描述】:
我使用下面的代码向 iPhone 添加了一个褪色的闪屏
UIImageView *splashView;
..
..
..
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,20, 320, 460)];
splashView.image = [UIImage imageNamed:@"Default.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.8];
[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 {
[splashView removeFromSuperview];
[splashView release];
}
这是针对我现在启用多任务处理的旧应用程序。我有一个问题,如果应用程序关闭(通过主页按钮或锁定)我想取消动画。我添加了以下代码以在应用关闭时删除启动视图
-(void) applicationDidEnterBackground:(UIApplication *)application
[splashView removeFromSuperview];
[splashView release];
}
如果应用程序在初始屏幕动画完成之前关闭应用程序将崩溃,因为初始屏幕在 applicationDidEnterBackground 中被删除,因此当 startupAnimationDone 被调用时(在 applicationDidEnterBackground 之后)没有什么可以删除所以它崩溃。
有没有办法取消applicationDidEnterBackground中的动画?
【问题讨论】:
-
请不要为 iPhone 应用程序启动闪屏!这不是标准 UI 体验的一部分。启动一些标准的 Apple 包含的应用程序; 任何有启动画面吗?
-
我同意,但这是客户的要求。他们将此用作广告空间,以使应用程序免费。
标签: ios multitasking splash-screen