从自定义相机中删除取消按钮 [英] Removing the cancel button from Custom camera
问题描述
我在相机上使用自定义叠加框架.在导航栏上,中间有应用程序图标,左侧有后退按钮.
I am using a custom overlay frame, on camera. On the navigation bar I have app icon in the middle and a back button on left.
所以我想删除除捕获按钮之外的默认取消按钮,但我不想删除相机单击按钮.我已经做了研究,但我没有找到完美的答案.我已经使用了以下代码,但它也删除了单击按钮.
So I would like to remove the default cancel button besides the capture button but I do not want to remove camera click button. I have done research but I did not find a perfect answer. I have already used the following code but it also removes the click button.
[picker setShowsCameraControls:YES];
推荐答案
我觉得您应该将自定义 CameraOverlayView 添加到您的 uiimagepickercontroller 并隐藏 CameraControls.这不会显示您的取消按钮.
I feel you you should add custom CameraOverlayView to your uiimagepickercontroller and hide CameraControls.This won’t show your cancel button.
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[picker setShowsCameraControls:NO];
CGRect screenBounds= [UIScreen mainScreen].bounds ;
UIView *overlayView = [[UIView alloc] initWithFrame:screenBounds];
[overlayView setAutoresizesSubviews:YES];
[overlayView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin]; UIButton *captureButton=[[UIButton alloc]initWithFrame:CGRectMake(screenBounds.size.width/2-30, screenBounds.size.height-60,60 , 60)];
[captureButton addTarget:self action:@selector(captureImage:) forControlEvents:UIControlEventTouchUpInside];
[captureButton setBackgroundImage:[UIImage imageNamed:@"icon"] forState:UIControlStateNormal];
[overlayView addSubview:captureButton];
[picker setCameraOverlayView:overlayView];
[picker setCameraDevice:UIImagePickerControllerCameraDeviceRear];
[self presentViewController:picker animated:YES completion:NULL];
这是捕获按钮的操作.
-(void)captureImage:(UIButton*)sender
{
[picker takePicture];
}
并使用此委托方法获取图像.
And use this delegate method to get image.
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissViewControllerAnimated:YES completion:nil];
}
这篇关于从自定义相机中删除取消按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!