Hide record button in UIImagePickerController

你说的曾经没有我的故事 提交于 2019-12-11 20:24:23

问题


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.

thanks for your helps...


回答1:


You can hide the controls of a UIImagePickerController by using:

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


来源:https://stackoverflow.com/questions/12313538/hide-record-button-in-uiimagepickercontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!