这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:尝试从对象插入nil对象‘*第一个抛出堆栈:(0x2e17af53 0x388faf 0x2e2b0x2b923b 0x2b0b9003 0x30961f39 0x306301ba1 0x308fa1b7 0x346f5e5b 0x8ec023 0x57524b 0x30570a5b 0x305708ed 0x305708/0x30708)
在iOS 2上运行iPad 7.0.2。
发布于 2013-10-07 04:17:24
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self addChildViewController:picker];
[self.view addSubview:picker.view];我已经在设备上测试过这一点,它运行得很好,看上去你还没有正确地检查,放置刹车点,并正确地检查您的应用程序崩溃在哪一行。
https://stackoverflow.com/questions/19216809
复制相似问题