我正在运行xcode-4.2,并且该项目基于ios5使用故事板。在AppDelegate中为iPhone应用程序添加splashscreen
我使用Apple提供的模板创建了单个视图应用程序。 在故事板中,我删除了为我创建的视图控制器并添加了一个UITabBarController。 接下来我添加了一个新类MyTabBarController,它是UITabBarController的一个子类。
现在我想在TabBar出现之前显示一个闪屏。所以我可以在后台做一些加载和计算。
我认为AppDelegate.m会是一个很好的地方。既然这是我的rootview得到加载的地方不是?或者应该在我的情况下从rootviewcontroller是MyTabBarController显示splashscreen?
所以我创建了一个xib文件。我很惊讶你可以将.xib文件添加到ios5故事板项目中。这个xib文件被称为SplashView.xib,它有一个带有图像的单一视图。在AppDelegate中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_splashScreen = [[UIViewController alloc] initWithNibName:@"SplashView" bundle:nil];
//_splashScreen is defined as:@property (strong, nonatomic) UIViewController *splashScreen;
[_window.rootViewController presentModalViewController:_splashScreen animated:NO];
[self performSelector:@selector(hideSplash) withObject:nil afterDelay:2];
return YES;
}
代码
的问题是什么也不会发生。即使我将值从2更改为200.应用程序启动时就好像没有闪屏一样。
正如你可能已经注意到,我仍然在Objective-C和iphone应用程序的设计中挣扎。我希望对我的问题作出恰当的回答会为这个问题带来一些清晰的结果。
在此先感谢!
{由[丹尼斯]从挂起的编辑移动(http://stackoverflow.com/users/713851/dennis)}虽然这是正确的,这不是苹果建议的,你不应该滥用启动画面的启动画面。 developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW1 –
-1,Apple特别声明不要使用启动画面在他们的HIG。 – lnafziger
你可以使用[NSThread sleepForTimeInterval:5.0],如果你需要启动画面来显示一些时间的话。 – Midas