2

I have created an app that displays a list of elements, where the user can present a modalview, by pressing a button. This works fine, and the user is able to present and dismiss several times.

The problem occurs when the user presses the home-button while the modalview is presented. I have set up a notification, to call a method when the app resigns, but it doesn't respond to dismiss modalview controller.

So when the user reenters the app, and tries to open the modalview controller nothings happens. After doing some debugging, I can see that self.modalViewController is set. So the modalview is still presented, but it's not visible, and I can't dismiss it.

Here is the code I use to present the modalview. At first I have a if-condition, that checks if self.modalViewController already exists:

if(self.modalViewController)
{
    NSLog(@"Modalview: %@", self.modalViewController);
}

//Present login
OrderContractController *occ = [[OrderContractController alloc] init];
occ.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[occ setMOC:self.context];
[self presentModalViewController:occ animated:YES];

It prints out the following: Modalview: <OrderContractController: 0x8483910>

How can I solve this?

1 Answer 1

2

You need to set self.modalViewController = nil when the modal view controller is removed, or when the app enters the background.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.