从UIImagePickerController捕获图像后显示黑色图像的相机

时间:2017-05-02 13:06:52

标签: ios

UIImagePickerControllerSourceType source = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] ? UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypeSavedPhotosAlbum;
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];
[self presentViewController:picker animated:YES completion:NULL];

使用UIImagePickerControllerSourceTypeSavedPhotosAlbum完成所有工作。所有权限都在plist中给出以保护隐私。改变了应用目标似乎没有什么对我有用。目前的应用目标是ios 8.

1 个答案:

答案 0 :(得分:0)

它不是答案。建议,请检查设备空间。 / ************** / 使用此代码:

 UIImagePickerController *picker = [[UIImagePickerController alloc] init];
   picker.sourceType = UIImagePickerControllerSourceTypeCamera;
  picker.delegate = self;
    picker.allowsEditing = YES;
    [self presentViewController:picker animated:YES completion:nil];

不要设置媒体类型

- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info
{

    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

 [picker dismissViewControllerAnimated:YES completion:nil];

}

/ *********许可***************** /

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<string>pro_name Camera Access</string>
</plist>