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?
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.
This is how Apple describes that option: