下面的代码创建一个弹出框控制器,UIImagePickerController
它使用 cameraOverlayView 来显示一个打开照片库的自定义按钮。
这在 iOS 5 上效果很好,但在 iOS 6 上,“拍照”按钮不见了,取而代之的是 - 在前置和后置摄像头按钮之间还有另一个切换!
请参阅以下屏幕截图 -
这是代码 - 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];
如果我删除[picker.cameraOverlayView addSubview:libraryButton]
,它可以正常工作,但是我的自定义按钮将消失(如预期的那样)。
那么为什么要分配cameraOverlayView
更改底部工具栏呢?
关于如何让“拍照”按钮回到 iOS 6 的任何线索?