这 4 行会导致应用程序崩溃。如果我更改UIImagePickerControllerSourceTypePhotoLibrary
为源类型,它就像一个魅力。它与我当前的应用程序无关。创建一个新项目并将这 4 行添加到 UIButton 中,它仍然崩溃。
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self addChildViewController:picker];
[self.view addSubview:picker.view];
我也试过
[self presentViewController:picker animated:YES completion:^{}];
和
popController = [[UIPopoverController alloc] initWithContentViewController:picker];
[popController presentPopoverFromRect:button.bounds inView:button permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
这一切都会导致这个崩溃:
* 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“* -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: 尝试从对象 [0] 插入 nil 对象” *第一次抛出调用堆栈:(0x2e17af53 0x388f06af 0x2e0b923b 0x2e0b9003 0x30961b39 0x30 0x308fa1b7 0x346f5e9b 0x308ec023 0x3057524b 0x30570a5b 0x305708ed 0x305702ff 0x3057010f 0x308e4343 0x2e1461d5 0x2e143b79 0x2e143ebb 0x2e0aece7 0x2e0aeacb 0x32d89283 0x30950a41 0x18135 0x38df8ab7) libc++abi.dylib: terminating with uncaught exception of type NSException
在 iPad 2 上运行 iOS 7.0.2。