I'm struggle at this for 2 days and believe that this is the moment I should call for help. After I search SOF for a while, none of any answer could solve my problem. Here are my application ...
In the application,
- Device is iPad, iOS 6
- RootViewController is NavigationController
- TopViewController is TabBarController
- In this TabBarController, I present a popoverController from right bar button of navigation bar
- In presenting popover there is a button to allow user to pick image from by taking new one or pick from existing.
- To pick new one, I presentViewController UIImagePickerController to allow user to take photo with divice camera. presentModalViewController:animated: if iOS < 6, and presentViewController:animated:completion: for iOS > 6
- I also hide Status Bar before presentation
- To select from existing photo, I do presentPopoverFromBarButtonItem:permitArrowDirections:animated:
- PopoverViewController also referencing by A TabBarController
Here is the issue
- Present UIImagePickerController will always failed if user try to pick new one first with exception "Application tried to present modally an active controller <[name of view controller that try to present]>"
- BUT, if user try to pick image from camera roll for once and then try to take new one again, it won't fail.
Here are what I tried
- present from RootViewController
- present from TopViewController (TabBarController)
- present from popoverViewController itself
- present from a tab of TabBarController
- hide popoverViewController before presentation
- resignFirstResponder from a textField in popoverViewController
Here is the current code I'm using
// PopoverViewController, presented by a tab in TabBarController
- (IBAction)takePhoto:(id)sender {
[self.delegate takePhotoWithDeviceCamera];
}
// A Tab in TabBarController, delegate of popoverViewController
- (void)takePhotoWithCamera {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
if ([UIDevice OSVersion] < 6.0) {
[self presentModalViewController:cameraPicker animated:YES];
} else {
[self presentViewController:cameraPicker animated:YES completion:nil];
}
}
Any idea what would cause this error? Any suggestion are welcome. Thank you.