I am very new to iOS development and have encountered a bug that I just cannot find a solution to. I searched everywhere for solutions, but perhaps it was my novelty that kept me from seeing the problem.
The exact warning that is printed in the log:
Trying to reject a view controller <_UIAlertShimPresentingViewController: 0x7aaa4b90> while a presentation or firing is in progress!
This happens right after I click on the button on the action bar.
Here is the code:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { if (buttonIndex == 0) { picker.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentViewController:picker animated:YES completion:nil]; } else if (buttonIndex == 1) { picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self presentViewController:picker animated:YES completion:nil]; } else if (buttonIndex == 2) { picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; [self presentViewController:picker animated:YES completion:nil]; } } else { if (buttonIndex == 0) { picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self presentViewController:picker animated:NO completion:NULL]; } else if (buttonIndex == 1) { picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; [self presentViewController:picker animated:YES completion:NULL]; } } }
Implementing actionSheet, I have an IBAction associated with the toolbar button located in the .xib file.
- (IBAction)addImage:(id)sender { UIActionSheet *popUpSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles: nil]; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { [popUpSheet addButtonWithTitle:@"Camera"]; [popUpSheet addButtonWithTitle:@"Photo Library"]; [popUpSheet addButtonWithTitle:@"Camera Roll"]; [popUpSheet addButtonWithTitle:@"Cancel"]; popUpSheet.cancelButtonIndex = popUpSheet.numberOfButtons-1; } else { [popUpSheet addButtonWithTitle:@"Photo Library"]; [popUpSheet addButtonWithTitle:@"Camera Roll"]; [popUpSheet addButtonWithTitle:@"Cancel"]; popUpSheet.cancelButtonIndex = popUpSheet.numberOfButtons-1; } [popUpSheet showFromBarButtonItem: self.toolbarItems[0] animated:YES]; }
Everything was delegated correctly from what I can say:
DetailViewController.m
@interface DetailViewController () < UINavigationControllerDelegate, UIImagePickerControllerDelegate >
DetailViewController.h
@interface DetailViewController : UIViewController <UIActionSheetDelegate>
Any insight would be appreciated and very helpful.
source share