gpt4 book ai didi

iphone - 在 UIImagePickerController 中隐藏记录按钮

转载 作者:行者123 更新时间:2023-11-28 20:30:30 38 4
gpt4 key购买 nike

我有一个关于 UIImagePickerController 的问题。我可以使用 UIImagePickerController 作为预览吗?如果我这样做,我必须隐藏录制按钮,有什么办法吗?或除 UIImagePickerController 之外的任何其他方法来显示我们的预览。

感谢您的帮助...

最佳答案

您可以使用以下方法隐藏 UIImagePickerController 的控件:

[myImagePickerController setShowsCameraControls:NO];

编辑:检查这段代码,它隐藏了图像选择器中的所有控件,允许您创建和添加自己的自定义控件。不幸的是,您不能有选择地隐藏选择器中的控件,所以这是替代方法。

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

关于iphone - 在 UIImagePickerController 中隐藏记录按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12313538/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com