这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对象 对象[0]” * 第一次抛出调用堆栈:(0x2e17af53 0x388f06af 0x2e0b923b 0x2e0b9003 0x30961f39 0x30961ba1 0x308fa1b7 0x346f5e9b 0x308ec023 0x3057524b 0x30570a5b 0x305708ed 0x305702ff 0x3057010f 0x308e4343 0x2e1461d5 0x2e143b79 0x2e143ebb 0x2e0aece7 0x2e0aeacb 0x32d89283 0x30950a41 0x18135 0x38df8ab7)libc ++ abi.dylib:终止于 NSException类型的未捕获异常
在iPad 2上运行iOS 7.0.2。
答案 0 :(得分:0)
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self addChildViewController:picker];
[self.view addSubview:picker.view];
我已经在设备上测试了它并且它工作很好看你没有正确检查刹车点并正确检查你的应用程序崩溃的哪一行