我在 iOS 9 上遇到了这种非常奇怪的行为,我有一个tableViewCell
这会打开一个imagePicker
当点击拍摄某物的照片时,当您第一次点击单元格时,需要大约 10 秒才能打开选择器,但是当您点击它两次时,它会立即打开...
选择器的初始化代码如下
let certificateImagePicker = UIImagePickerController()
certificateImagePicker.delegate = self
certificateImagePicker.allowsEditing = false
certificateImagePicker.sourceType = .Camera
certificateImagePicker.modalPresentationStyle = .CurrentContext
呈现选择器的代码是presentViewController(certificateImagePicker, animated: false, completion: nil)
我现在不知道它是否相关,但打开选择器后它显示此错误消息
对尚未渲染的视图进行快照会产生空快照。
确保您的视图在拍摄快照之前至少已渲染一次或
屏幕更新后的快照。
我在提交论文时也经历过类似的延迟UIImagePickerController
第一次尝试。对我来说有很大帮助的是在初始化父级的同时初始化它UIViewController
,像这样:
class ExampleViewController: UIViewController, UIImagePickerControllerDelegate {
let imagePicker = UIImagePickerController()
func presentImagePicker() {
imagePicker.delegate = self
imagePicker.allowsEditing = false
imagePicker.sourceType = .camera
imagePicker.modalPresentationStyle = .currentContext
self.present(imagePicker, animated: false, completion: nil)
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)