After a user selects a picture from their photo library I want to dismiss the imagePickerVierController and present another, but get the error:
Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress!
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if (!self.submitPicturesDetailsViewController)
{
self.submitPicturesDetailsViewController = [[SubmitPictureDetailsViewController alloc] initWithPicture: lPicture];
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
[self.submitPicturesDetailsViewController setModalPresentationStyle:UIModalPresentationFormSheet];
[self.popOver dismissPopoverAnimated:YES];
[self presentViewController: self.submitPicturesDetailsViewController animated:YES completion: nil];
}else
{
//[self performSelector:@selector(present) withObject: nil afterDelay: 5.0];
[self dismissViewControllerAnimated:NO completion:^{
[self presentViewController: self.submitPicturesDetailsViewController animated:YES completion: nil];
}];
}
}
I have tried:
[self performSelector:@selector(present) withObject: nil afterDelay: 5.0];
And it works properly so apparently the completion block is not working properly.
The best fool-proof solution I found was to recursively call my method until the prior view controller is no longer loaded.
- (void) present
{
if (!self.submitPicturesDetailsViewController.isViewLoaded) {
[self presentViewController: self.submitPicturesDetailsViewController animated:YES completion: nil];
}else{
[self performSelector:@selector(present) withObject: nil afterDelay: 0.1];
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.