UIImagePickerController相机预览在ios9中变黑

时间:2015-09-18 12:08:31

标签: ios uiimagepickercontroller

我在Xcode 7中编写以下代码并运行app in:

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = `enter code here`(id)self;
picker.sourceType=UIImagePickerControllerSourceTypeCamera;
[self.navigationController presentViewController:picker animated:YES completion:nil];

但ios9中的相机预览会变黑,我收到此警告:

  

我的快照未渲染的视图导致空白   快照。确保您的视图至少在之前呈现过一次   屏幕更新后的快照或快照

2 个答案:

答案 0 :(得分:1)

试试这段代码:

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

确保您的设备设置如下所示:

iPhone 6 device settings

答案 1 :(得分:0)

我终于通过创建一个新项目解决了我的问题。可能在升级期间发生了一些错误,因为这种情况正在发生,特别是对于我的这个项目。新项目正在运行相机和放大器。画廊成功。