The following code creates a popover controller with a UIImagePickerController
that uses cameraOverlayView to show a custom button that opens photo library.
This works great on iOS 5, but on iOS 6 the "Take Photo" button is missing, instead - there's another switch between front and back camera button!
See the following screenshot -
This is the code - UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ( ![UIImagePickerController isSourceTypeAvailable: sourceType] ) {
[self openLibrary: sender];
return;
}
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = sourceType;
UIButton *libraryButton = [UIButton buttonWithType: UIButtonTypeCustom];
libraryButton.frame = CGRectMake(12, 12, self.photoLibraryIcon.size.width, self.photoLibraryIcon.size.height);
[libraryButton setImage: self.photoLibraryIcon forState: UIControlStateNormal];
[libraryButton addTarget: self action: @selector(openLibrary:) forControlEvents: UIControlEventTouchUpInside];
[picker.cameraOverlayView addSubview:libraryButton];
__imagePickerPopoverController = [[UIPopoverController alloc] initWithContentViewController: picker];
self.imagePickerPopoverController.delegate = self;
[self.imagePickerPopoverController presentPopoverFromRect: CGRectMake(self.center.x - 5, self.center.y - 5, 10, 10)
inView: self.superview
permittedArrowDirections: UIPopoverArrowDirectionAny
animated: YES];
If I remove the [picker.cameraOverlayView addSubview:libraryButton]
, it works fine, but then my custom button will be gone (as expected).
So why assigning a cameraOverlayView
changes the bottom toolbar?
Any clue on how to get the "Take Photo" button back to iOS 6?