简体   繁体   English

从自定义相机中删除取消按钮

[英]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. 在导航栏上,我在中间有app图标,左边有一个后退按钮。

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];

I feel you you should add custom CameraOverlayView to your uiimagepickercontroller and hide CameraControls.This won't show your cancel button. 我觉得你应该为你的uiimagepickercontroller添加自定义CameraOverlayView并隐藏CameraControls.This不会显示你的取消按钮。

 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];

And this is action for Capture button. 这是Capture按钮的动作。

-(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];
}

I think you disable but about removing i am not sure as I know it is not possible because UIImagePickerController inherits UINavigationController. 我认为你禁用但关于删除我不确定,因为我知道这是不可能的,因为UIImagePickerController继承UINavigationController。 Then you can get 那你就可以搞定

UINavigationBar *bar = picker.navigationBar;
[bar setHidden:NO];
bar.navigationItem.rightBarButtonItem = doneButton;

It will work only for IOS 6 它仅适用于IOS 6

You can use this source ELCImagePickerController 您可以使用此源ELCImagePickerController

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM