簡體   English   中英

UIImagePickerController與UIImagePickerControllerSourceTypeCamera崩潰

[英]UIImagePickerController with UIImagePickerControllerSourceTypeCamera crash

我有以下代碼:

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和iPhone上。 如果我注釋“ present”方法,它不會崩潰,但是在逐行注釋每一行之后,我發現這是唯一使我的應用程序崩潰的方法(沒有它,“ present”方法有效,它將我帶到庫中) ):

[cameraUI setSourceType:UIImagePickerControllerSourceTypeCamera];

我真的沒有主意了。 誰能幫我嗎?

我發現了問題,也許有人有時會遇到相同的問題...我需要在我的應用程序內的所有按鈕上設置一個屬性,因此我創建了一個UIButton類別,其中我覆蓋了-initWithFrame:這導致崩潰。 顯然,相機UI需要在那里發生的事情不再發生。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM