I´m new to xcode but I keep on making some small apps to learn. I have run into a problem that only sometimes occurs with the message "Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress!" and the app then crash. I have searched around and found some possible answers but no luck for me yet. Original code is: - (IBAction)Back { UIViewController *back = [[UIViewController alloc] initWithNibName:nil bundle:nil]; [self presentViewController:back animated:NO completion:NULL]; [self.view.window.rootViewController dismissViewControllerAnimated:NO completion:nil]; }
Last modified code: - (IBAction)Back { UIViewController *back = [[UIViewController alloc] initWithNibName:nil bundle:nil]; [self presentViewController:back animated:NO completion:NULL]; [self.view.window.rootViewController dismissViewControllerAnimated:NO completion:^{ [(UINavigationController *)self.presentingViewController popToRootViewControllerAnimated:YES]; }];}
I understand that the problem is that I try to go from one viewcontroller to another before the presentation of the viewcontroller is done.
The strangest thing is that this sometimes isn´t any problem and the app works flawlessly.
Aucun commentaire:
Enregistrer un commentaire