带有活动指示器的启动屏幕在iOS6中工作正常,但在iOS5中工作不正常
我想显示一个带有活动指示器的闪屏视图,以便在进入我的应用程序之前从服务器加载一些信息。以下是我的做法:带有活动指示器的启动屏幕在iOS6中工作正常,但在iOS5中工作不正常,ios5,ios6,splash-screen,Ios5,Ios6,Splash Screen,我想显示一个带有活动指示器的闪屏视图,以便在进入我的应用程序之前从服务器加载一些信息。以下是我的做法: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
FeedViewController *feedViewController = [[FeedViewController alloc] initWithNibName:@"FeedViewController" bundle:nil];
MenuViewController *menuViewController=[[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:feedViewController];
IIViewDeckController* deckController = [[IIViewDeckController alloc] initWithCenterViewController:self.navController leftViewController:menuViewController rightViewController:nil];
deckController.panningMode=IIViewDeckNoPanning;
deckController.panningView=menuViewController.view;
self.window.rootViewController = deckController;
[self.window makeKeyAndVisible];
// show splash screen until data is loaded
SplashScreenViewController *controller = [[SplashScreenViewController alloc] initWithNibName:@"SplashScreenViewController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[feedViewController presentModalViewController:controller animated:NO];
return YES;
}
在FeedViewController.m中,我做了如下操作:
- (void)viewDidLoad
{
// load data from a server
[self performSelector:@selector(dismissSplashScreen) withObject:nil afterDelay:0.0];
}
这段代码在iOS6上运行得非常好,但是当我在iOS5上测试它时,活动指示器旋转的初始屏幕并没有消失。我怀疑我可能以错误的方式实现了启动屏幕。(但我不明白为什么在iOS6中这样做?我自己解决了这个问题,使用bool变量检查是否应该显示启动屏幕。显示启动屏幕的代码移到FeedViewController的
viewDidLoad
这种方法似乎对iOS5和iOS6都很有效。如果只删除
dismissssplashscreen
部分,它会显示在iOS5中吗?还可以尝试此[deckController presentModalViewController:controller动画:否]代码>。我尝试了你的两个建议,但问题仍然存在。