我已经阅读了该网站上的许多帖子(尤其是:iOS 8 Snapshotting a view that has not been rendering 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。