First let me tell you what I'm trying to do:
UIPopoverController
with a UINavigationController
as its contentViewController
(this is on an iPad)UIViewController
pushed into UINavigationController
will be a custom view controller that has 2 buttons: "take picture" and "select from library". setSourceType:UIImagePickerControllerSourceTypeCamera
on the UIImagePickerController
and push it into the UINavigationController
setSourceType:UIImagePickerControllerSourceTypePhotoLibrary
on the UIImagePickerController
and push it into the UINavigationController
I want to be able to do all of this and be able to allow a user to navigate backwards as the UINavigationController allows.
The problem is that since UIImagePickerController
is also a UINavigationController
, I cannot push it into another UINavigationController
as stated in #3 and #4.
Questions:
UIImagePickerController
with a custom view controller pushed before the camera / photo library view controllers? UINavigationController
?Adding the following code (as detailed here) was what finally solved this question for me.
Use the navigationController:willShowViewController:animated:
method to access the navigationBar.
then with this code you can add a "cancel" button.
if ([navigationController isKindOfClass:[UIImagePickerController class]]) {
UINavigationBar *bar = navigationController.navigationBar;
UINavigationItem *top = bar.topItem;
UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(imagePickerControllerDidCancel:)];
[top setLeftBarButtonItem:cancel];
} else {
//do non imagePickerController things
}