取消自定义相机的取消button
我在相机上使用自定义覆盖框架。 在导航栏上我有中间的应用程序图标和左侧的后退button。
所以我想删除捕获button除了默认的取消button,但我不想删除相机点击button。 我做了研究,但没有find完美的答案。 我已经使用下面的代码,但它也删除了点击button。
[picker setShowsCameraControls:YES];
我觉得你应该添加自定义CameraOverlayView到你的uiimagepickercontroller并隐藏CameraControls.This不会显示你的取消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];
这是捕获button的操作。
-(void)captureImage:(UIButton*)sender { [picker takePicture]; }
并使用这个委托方法来获取图像。
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissViewControllerAnimated:YES completion:nil]; }
我认为你禁用,但关于删除我不知道,因为我知道这是不可能的,因为UIImagePickerControllerinheritanceUINavigationController。 那么你可以得到
UINavigationBar *bar = picker.navigationBar; [bar setHidden:NO]; bar.navigationItem.rightBarButtonItem = doneButton;
它只能用于IOS 6
你可以使用这个源ELCImagePickerController