iphone - Modal view controller disappears?
So let's say I have a viewController named homeViewController, and another view controller named listViewController
I display listViewController on top of homeViewController as a modal. If the user clicks the off button, and then comes back to the app the modalViewController is gone.
ListViewController *listViewController = [[ListViewController开发者_开发知识库 alloc] init];
[self presentModalViewController:listViewController animated:NO];
[listViewController release];
Note: Application doesn't startup from scratch when this occures and the previous state is still visible
I'm assuming that by "off button" you mean the user locks the iDevice.
I just tried this in one of my apps and the modal view controller is still there after unlocking. My guess would be that it's something unrelated to the code you have posted. I would check your - (void)applicationWillResignActive:(UIApplication *)application
method in your app delegate class and see if there's anything there that would dismiss the modal view controller.
Here is what the problem was. When the user locks the screen I remove homeViewController from window
[homeViewController removeFromSuperview];
When user starts the app again I do
[windows addSubview:homeViewController];
that brings homeViewController on top of its modeal
精彩评论