我在相机上使用自定义叠加框架。在导航栏上,我在中间有app图标,左边有一个后退按钮。
所以我想删除捕获按钮旁边的默认取消按钮,但我不想删除相机点击按钮。我做过研究,但没有找到完美的答案。我已经使用了以下代码,但它也删除了单击按钮。
[picker setShowsCameraControls:YES];
答案 0 :(得分:9)
我觉得你应该为你的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];
这是Capture按钮的操作。
-(void)captureImage:(UIButton*)sender
{
[picker takePicture];
}
并使用此委托方法获取图像。
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissViewControllerAnimated:YES completion:nil];
}
答案 1 :(得分:3)
我认为你禁用但关于删除我不确定,因为我知道这是不可能的,因为UIImagePickerController继承了UINavigationController。然后你可以得到
UINavigationBar *bar = picker.navigationBar;
[bar setHidden:NO];
bar.navigationItem.rightBarButtonItem = doneButton;
它仅适用于IOS 6
您可以使用此来源ELCImagePickerController