问题
I tried to load a splashscreen on top of a tabbarcontroller in my application. No apple HIG references please, the aim of this splashscreen is to check for connectivity, then check for content update.
What's would be done in case of update Splashscreen -> update view -> tabbarcontroller In case of nothing Splashscreen -> tabbarcontroller
I present the update view modaly from the splashscreen view controller.
I'm unable to have the splashscreen loaded each time the app is launched and when the app comes back from background.
on the appdelegate I use:
self.firstViewController = [[FirstViewController alloc]
initWithNibName:nil
bundle:NULL];
self.secondViewController = [[SecondViewController alloc]
initWithNibName:nil
bundle:NULL];
self.thirdViewController = [[ThirdViewController alloc]
initWithNibName:nil
bundle:NULL];
NSArray *twoViewControllers = [[NSArray alloc]
initWithObjects: self.firstViewController, self.secondViewController, self.thirdViewController, nil];
self.tabBarController = [[UITabBarController alloc] init];
[self.tabBarController setViewControllers:twoViewControllers];
self.window.rootViewController = self.tabBarController;
self.ecranDemarrage = [[SplashViewController alloc] init];
self.ecranDemarrage.showsStatusBarOnDismissal = YES;
self.ecranDemarrage.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.window makeKeyAndVisible];
[self.tabBarController presentModalViewController:self.ecranDemarrage animated:YES];
Well, the splashscreen is displayed after the tabbarcontroller... Not a good point.
I tried to launch on applicationdidbecomeactive notification, works but always shows the tabbarcontroller first then the splashscreen.
I tried to add the splashscreen view as a subview before making window visible, not much success either.
Could someone point me in the right direction in order to have the splashscreen loaded before anything else?
回答1:
1- Did you add Default.png
& Default@2x.png
?? If yes then splash screen shows up automatically
2- You can also do this:(Mostly this is done when you have some functionality to perform after application launches, like you want to download data from web server or setup some application setting etc.)
Add you splashcontroller
as a rootcontroller
in AppDelegate
, and then present the TabbarController as modal or again get the reference of AppDelegate in the SpalshController and change the RootViewController
to TabbarController
.
来源:https://stackoverflow.com/questions/13551824/splashscreen-to-check-update-on-top-of-tabbarcontroller