简体   繁体   English

在UIImagePickerController中隐藏记录按钮

[英]Hide record button in UIImagePickerController

I have a question on UIImagePickerController. 我对UIImagePickerController有疑问。 May I use UIImagePickerController as a preview? 我可以使用UIImagePickerController作为预览吗? If I do like that, I have to hide record button, is there any way to do it? 如果我喜欢这样做,就必须隐藏“记录”按钮,有什么办法吗? or Any other approach to show our preview other than UIImagePickerController. 或除UIImagePickerController以外的任何其他显示预览的方法。

thanks for your helps... 谢谢你的帮助...

You can hide the controls of a UIImagePickerController by using: 您可以使用以下方法隐藏UIImagePickerController的控件:

[myImagePickerController setShowsCameraControls:NO];

EDIT: Check out this code, it hides all the controls inside the image picker allowing you to create and add your own custom controls. 编辑:签出这段代码,它将所有控件隐藏在图像选择器中,从而允许您创建和添加自己的自定义控件。 Unfortunately you can not selectively hide controls within the picker so this is the alternative. 不幸的是,您无法在选择器中有选择地隐藏控件,因此这是替代方法。

- (void)showCamera
{
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {

        myImagePicker = [[UIImagePickerController alloc] init];

        [myImagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
        [myImagePicker setDelegate:self];
        [myImagePicker setShowsCameraControls:NO];
        UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
        UIButton *switchCameraButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [switchCameraButton setFrame:CGRectMake(10, 430, 72, 40)];
        [switchCameraButton addTarget:self action:@selector(changeCamera:) forControlEvents:UIControlEventTouchUpInside];
        [overlayView addSubview:switchCameraButton];
        [myImagePicker setCameraOverlayView:overlayView];
        [self presentViewController:myImagePicker animated:YES completion:nil];

    }
}
- (IBAction)changeCamera:(id)sender
{
    if (myImagePicker.cameraDevice == UIImagePickerControllerCameraDeviceFront) {
        [myImagePicker setCameraDevice:UIImagePickerControllerCameraDeviceRear];
    }else{
        [myImagePicker setCameraDevice:UIImagePickerControllerCameraDeviceFront];
    }
}

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

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