Reputation: 11
I have the following code:
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");
}];
and I get this crash:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
It happens on iOS7, iOS8, iPad & iPhone. If I comment the "present" method, it doesn't crash, but after commenting each line one by one, I found that this is the only one that crashes my app (without it the "present" works and it takes me to library):
[cameraUI setSourceType:UIImagePickerControllerSourceTypeCamera];
I'm really out of ideas here. Can anyone help me out?
Upvotes: 0
Views: 157
Reputation: 11
I found the problem, maybe someone will encounter the same problem sometime... I needed a property set on all the buttons inside my app, so I created a UIButton
category in which I had overridden -initWithFrame:
, and this caused the crash. Apparently something needed to happen there for the camera UI that wasn't happening anymore.
Upvotes: 1