UIImagePickerController与UIImagePickerControllerSourceTypeCamera崩溃

时间:2015-03-16 08:11:03

标签: ios

我有以下代码:

if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
    [[[UIAlertView alloc] initWithTitle:@"Error" message:@"Camera is not available." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil] show];
    return;
}

UIImagePickerController * cameraUI = [[UIImagePickerController alloc] init];
[cameraUI setSourceType:UIImagePickerControllerSourceTypeCamera];
[cameraUI setMediaTypes:@[(NSString*)kUTTypeMovie]];
[cameraUI setAllowsEditing:NO];
[cameraUI setDelegate:self];

[navigationController presentViewController:cameraUI animated:YES completion:^{

    NSLog(@"completed present camera controller");

}];

我得到了这个崩溃:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'

它发生在iOS7,iOS8,iPad和iPad上。苹果手机。 如果我评论“现在”的方法,它不会崩溃,但在逐行评论每一行后,我发现这是唯一一个崩溃我的应用程序(没有它“现在”工作,它带我到图书馆):

[cameraUI setSourceType:UIImagePickerControllerSourceTypeCamera];

我真的没有想法。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

我发现了问题,也许有人会在某个时候遇到同样的问题...我需要在我的应用内的所有按钮上设置属性,所以我创建了一个UIButton类别,其中我已覆盖{{1这导致了崩溃。显然,相机用户界面需要发生的事情不再发生了。