gpt4 book ai didi

ios - 打开自定义相机时出错(Objective-c)

转载 作者:行者123 更新时间:2023-11-28 19:37:11 24 4
gpt4 key购买 nike

我尝试制作一个自定义相机,但它不起作用。我还需要添加一个叠加层,但我不知道如何。有人可以帮助我吗?

    - (IBAction)AbrirCamara:(id)sender {
UIImagePickerController *picker = [UIImagePickerController new];
picker.delegate = self;

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{



picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.wantsFullScreenLayout = YES;



picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:nil];
}}

这是错误。

      Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type must be UIImagePickerControllerSourceTypeCamera'
*** First throw call stack:
(0x2ed43f0b 0x394dace7 0x317cf6d9 0x317cf551 0xdc7e7 0x315a86c7 0x315a8663 0x315a8633 0x31593d7b 0x315a807b 0x3156b541 0x315a3325 0x315a2c4b 0x31577e75 0x31576541 0x2ed0efef 0x2ed0e4b7 0x2ed0cca7 0x2ec77769 0x2ec7754b 0x33be46d3 0x315d6891 0xde565 0x399d8ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException

最佳答案

UIImagePickerController *picker = [UIImagePickerController new];
picker.delegate = self;

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{

picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.wantsFullScreenLayout = YES;

[self presentViewController:picker animated:YES completion:nil];
}

你的问题是你在下面写了 sourceType 发生了错误。在您设置其他 Controller 之后首先设置 SourceType。

关于ios - 打开自定义相机时出错(Objective-c),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37608003/

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