问题描述:

when i close my application (via HOME button) and open it up again, how do i force the application to restart from the very beginning view and not from the last location that was shown (before it was closed)? is it a setting in the project?

网友答案:

Set the app's info.plist key: UIApplicationExitsOnSuspend to True.

网友答案:

Look for a notification from the phone letting you know that the phone "Became Active" which will only happen if the app was running, then sent to background, then pulled up again. Once you know it has become active again you can push your Home view.

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    if (application.applicationState == UIApplicationStateInactive ) {
         //application has been sent to the background
    }

    if(application.applicationState == UIApplicationStateActive ) { 
        //The application has become active an alert view or do something appropriate.
        //push home view here.
    }
}
网友答案:

This is caused by multi-tasking, i.e. the app isn't properly quitting.

To ensure that it pops back, try this in the applicationWillEnterForeground, like so:

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [self.navigationController popToRootViewControllerAnimated:NO];
}

Or a very quick and dirty way, is to actually quit the application when it enters the background (note this probably isn't the best way).

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [[NSThread mainThread] exit];
    // OR
    exit(0);
}
相关阅读:
Top