Question

When I click the home button on the device. This is a part of my delegate:

- (void)applicationWillResignActive:(UIApplication *)application
{
    NSLog(@"resign active");
    //[[NSThread mainThread] cancel];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    NSLog(@"enter background");
    //[[NSThread mainThread] cancel];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    NSLog(@"enter foreground");
    //[[NSThread mainThread] cancel];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
    NSLog(@"terminate");
    //[[NSThread mainThread] cancel];
}

I uses NSLog to understand which method are called when I click the Home Button. This is output in console.

2012-01-20 15:55:55.853 MyApp[5955:11f03] enter background
2012-01-20 15:55:55.855 MyApp[5955:11f03] terminate
Program ended with exit code: 0

So, when I click on app in background (clicking two time the home button), it launchs again showing the first image and then my first uiviewcontroller.

In which way I can resolve it, and resume app from uiviewcontroller that was on the top when user clicks home button?

Was it helpful?

Solution

Check your info.plist file and make sure that "Application does not run in background" is not checked.

The image below shows the option in state "on", so that when the user press the home button, the app is effectively finalized.

info.plist configuration

This is how Apple describes that option:

UIApplicationExitsOnSuspend

UIApplicationExitsOnSuspend (Boolean - iOS) specifies that the application should be terminated rather than moved to the background when it is quit. Applications linked against iOS SDK 4.0 or later can include this key and set its value to YES to prevent being automatically opted-in to background execution and application suspension. When the value of this key is YES, the application is terminated and purged from memory instead of moved to the background. If this key is not present, or is set to NO, the application moves to the background as usual.

This key is supported in iOS 4.0 and later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top