问题描述
我有一个关于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中隐藏记录按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!