我真的很难弄清楚如何做到这一点。我有一个UIImagePickerController
工作正常,但我想创建自己的CameraOverlayView
,以便我可以自定义按钮。我似乎无法弄清楚如何首先创建叠加层。我已经尝试了很多教程,并且已经达到了以下内容,但是还差得很远。谁能给我指出一个简单易懂的说明?
- 我创建了一个
UIImagePickerController
适用于标准控件的 - 对于叠加层,我
UIViewController
在情节提要上创建了一个新的并将其链接到一个名为的新类ObViewControllerCameraOverlay
在
startCameraControllerFromViewController
我使用以下方法隐藏标准控件cameraUI.showsCameraControls=否;
然后显示cameraOverlay(不编译)
obViewControllerCameraOverlay *overlay = [[obViewControllerCameraOverlay alloc]; cameraUI.cameraOverlayView = 覆盖;
我知道我做错了,但我不知道如何做到这一点。我也看过 Apple 的 PhotoPicker,但我就是不明白。
更新:
我现在在哪里 - 谁能告诉我这是否是正确的过程(我意识到需要对帧大小进行排序并且需要以某种方式添加自定义按钮):
“拍照”所在的 .m 文件UIButton
。
@property (nonatomic, strong) UIView *overlay;
- (IBAction)takePhoto:(id)sender
{
[self startCameraControllerFromViewController: self usingDelegate: self];
}
- (BOOL) startCameraControllerFromViewController: (UIViewController*) controller usingDelegate: (id <UIImagePickerControllerDelegate, UINavigationControllerDelegate>) delegate
{
if (([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] == NO) || (delegate == nil) || (controller == nil)) return NO;
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerCameraCaptureModePhoto];
cameraUI.showsCameraControls=NO;
overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
cameraUI.cameraOverlayView = overlay;
cameraUI.allowsEditing = NO;
cameraUI.delegate = delegate;
[controller presentViewController:cameraUI animated:YES completion:nil];
return YES;
}