【问题标题】:Removing the cancel button from Custom camera从自定义相机中删除取消按钮
【发布时间】:2015-09-14 12:26:58
【问题描述】:

我在相机上使用自定义叠加框。在导航栏上,我在中间有一个应用程序图标,在左侧有一个后退按钮。

所以我想删除除捕获按钮之外的默认取消按钮,但我不想删除相机点击按钮。我做了研究,但我没有找到一个完美的答案。我已经使用了以下代码,但它也删除了点击按钮。

[picker setShowsCameraControls:YES];

【问题讨论】:

    标签: ios objective-c uinavigationbar


    【解决方案1】:

    我觉得你应该将自定义 CameraOverlayView 添加到你的 uiimagepickercontroller 并隐藏 CameraControls。这不会显示你的取消按钮。

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

    并使用此委托方法获取图像。

    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        [picker dismissViewControllerAnimated:YES completion:nil];
    }
    

    【讨论】:

      【解决方案2】:

      我认为你禁用但关于删除我不确定,因为我知道这是不可能的,因为 UIImagePickerController 继承了 UINavigationController。然后就可以得到

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

      它仅适用于 IOS 6

      你可以使用这个来源ELCImagePickerController

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-28
      • 2018-11-25
      • 2012-07-15
      • 2011-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多