启用限制抛出NSException同时打开相机

问题描述:

我已经启用了限制和禁止的相机和FaceTime公司在ipad的设置和隐私选项卡,我禁用了访问的照片我的应用程序。启用限制抛出NSException同时打开相机

我打开使用以下代码相机和照片库,

//For camera 
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
picker.delegate = self; 
picker.allowsEditing = NO; 
[self.view.window.rootViewController presentViewController:picker animated:YES completion:nil]; 

//For Photo library 
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
picker.delegate = self; 
picker.allowsEditing = NO; 
[self.view.window.rootViewController presentViewController:picker animated:YES completion:nil]; 

虽然打开照片库,它清楚地显示该访问被拒绝的消息,它可以在设置的应用程序来改变。但是,在打开摄像头,应用程序崩溃引发错误,

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type 1 not available' *** First throw call stack: (0x30584f4b 0x3ac566af 0x32f56d69 0x1141d9 0x32ee4d03 0x32d2c713 0x32d2c6b3 0x32d2c691 0x32d1811f 0x32d2c107 0x32d2bdd9 0x32d26e65 0x32cfc79d 0x32cfafa3 0x30550183 0x3054f653 0x3054de47 0x304b8c27 0x304b8a0b 0x3518c283 0x32d5c049 0xeff7d 0x3b15eab7) libc++abi.dylib: terminating with uncaught exception of type NSException

如何解决这一问题?

您应经常检查阉源类型可供选择:

从Apple UIImagePickerController doucmentatiom

确保设备能够从所期望的 源选择内容。执行此调用isSourceTypeAvailable:类方法, 提供恒定从UIImagePickerControllerSourceType 枚举。

请检查是否提供源代码,如:

if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary]) { 
// UIImagePickerControllerSourceTypePhotoLibrary is available. 
}