This is something strange to me. In my tabbar based application, application is not starting with start of first view in a tab, but instead of where i quit application? How to make sure that my app always start from first view in my first tab?
开发者_如何学Go - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
return YES;
}
In case your application is running in background, add the following code:
- (void)applicationWillEnterForeground:(UIApplication *)application {
tabBarController.selectedIndex = 0;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
}
you have to take care of this method on appdelegate.m like
- (void)applicationDidBecomeActive:(UIApplication *)application {
[tabController setSelectedIndex:0];
}
[Updated] check "DarkDust"'s link for your requirement
Are you sure you're exiting the app and not just 'minimizing' it to the background?
Double-press the 'home' button of the iPhone to see the apps that are running in the background.
Users will expect to come back to the app where they left it in general. Overriding this behaviour is probably not a good idea. You CAN add a key for UIApplicationExitsOnSuspend to your plist and set it to true which will force multi-tasking phones to relaunch your app from scratch each time, but you really need to consider if this is the correct thing to do. It almost certainly isn't!
As in comment i said to start the app every time from the home screen i use in appdelegate this try it out:
- (void)applicationWillResignActive:(UIApplication *)application
{
exit(1);
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
exit(1);
}
hope it helps
wblade
精彩评论