Jack Sierkstra
Jack Sierkstra

Reputation: 1434

Dismissing and presenting modalviewcontrollers

Goodday,

I got an application where an user logs in, and when the log in details is correct, the modalviewcontroller is dismissed. After the viewcontroller is dismissed, another view controller is called upon. This all goes fine except for the fact, when i want to switch back to my original controller: My login controller. I got the following code:

This code is called when the user logs in:

[self dismissModalViewControllerAnimated:YES];
Form *formcontroller1 = [[Form1 alloc] init];
[self presentModalViewViewController:formcontroller1 animated:YES];

After the user logged in, there is a logout button wich calls the following code:

[self dismissModalViewControllerAnimated:YES];
Postform3ViewController *logincontroller = [[Postform3ViewController alloc] init];
[self presentModalViewViewController:logincontroller animated:YES];

After the button is clicked, i get the following error message:

Postform3[5848:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from to while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed'

And i wonder if anyone can help me with this problem..

Upvotes: 0

Views: 5301

Answers (1)

user23743
user23743

Reputation:

Actually, the error message tells you exactly what you need to do. You're dismissing a modal view controller, but not waiting until it's been dismissed before trying to present another. You should present the second view controller later, after -viewDidDisappear: has been invoked by the view controller machinery.

Upvotes: 2

Related Questions