我在这个网站上看过很多帖子(特别是这个:iOS 8 Snapshotting a view that has not been rendered results in an empty snapshot)但是Swift没有答案。
以为如果他们已经解决了这个问题,我会问这里的人群。
我在iPhone 6上使用Xcode 6.2,iOS 8.2
我的代码:
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
if(UIImagePickerController .isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)){
imag = UIImagePickerController()
imag.delegate = self
imag.sourceType = UIImagePickerControllerSourceType.Camera;
imag.allowsEditing = false
imag.mediaTypes = [kUTTypeImage]
imag.showsCameraControls = false
self.presentViewController(imag, animated: true, completion: nil)
imag.cameraDevice = UIImagePickerControllerCameraDevice.Front
imag.takePicture()
}
}
如果我将此(self.presentViewController(imag,animated:true,completion:nil))改为(self.presentViewController(imag,animated:YES,completion:nil)),我得到并错误切换回true
答案 0 :(得分:0)
我在控制台中收到相同的警告,但其他一切都应该有效。如果相机未显示,请在设备设置中检查相机权限。