在UIImagePickerController中隐藏记录按钮 [英] Hide record button in UIImagePickerController

查看:359
本文介绍了在UIImagePickerController中隐藏记录按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于UIImagePickerController的问题。我可以使用UIImagePickerController作为预览吗?如果我这样做,我必须隐藏记录按钮,有什么办法吗?

I have a question on UIImagePickerController. May I use UIImagePickerController as a preview? 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 的控件:

You can hide the controls of a UIImagePickerController by using:

[myImagePickerController setShowsCameraControls:NO];

编辑:检查此代码,隐藏图像选择器,允许您创建和添加自己的自定义控件。很遗憾,您无法选择性地隐藏选择器中的控件,因此这是替代方案。

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

这篇关于在UIImagePickerController中隐藏记录按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆