this question ask again但我找不到ios 10
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera)
{
self.imagePicker.delegate = self
self.imagePicker.sourceType = UIImagePickerControllerSourceType.camera;
self.imagePicker.allowsEditing = false
self.imagePicker.cameraCaptureMode = .photo
//self.imagePicker.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
self.present(self.imagePicker, animated: true, completion: nil)
self.imagePicked.isUserInteractionEnabled = true
}
else
{
print("No Camera")
}
快照未渲染的视图会导致空白 snapshot.Ensure您的视图至少已呈现过一次 屏幕更新后的快照或快照。
当我旋转相机并拍摄时,发生此错误。
答案 0 :(得分:4)
自我解决方案像魅力一样为我工作:-)希望它对所有人有用
*.java
答案 1 :(得分:3)
我收到了错误
此应用程序正在从后台线程修改autolayout引擎,这可能导致引擎损坏和奇怪的崩溃......
使用DispatchQueue.main.async
代替我。
答案 2 :(得分:0)
此行为不仅限于UIImagePickerController。下面是一个UIViewController的示例,它以模态方式呈现另一个UIViewController。在第二个UIViewController中,启动Safari以显示URL,从而触发相同的错误消息,"不能使用afterScreenUpdates快照视图(>):NO,因为视图不在窗口中。使用afterScreenUpdates:YES。"
我还没有找到任何抑制消息的方法,但在我的应用中它没有任何伤害。我认为这里发生的是一些Apple代码正在拍摄应用程序视图层次结构的快照,但键盘(由一个单独的UIWIndow拥有)在拍摄快照之前尚未呈现
/* Generates the error message:
Cannot snapshot view (<UIKeyboardImpl: 0x7f82ded12ea0; frame = (0 0; 414 271); layer = <CALayer: 0x610000035e20>>) with afterScreenUpdates:NO, because the view is not in a window. Use afterScreenUpdates:YES.
... after the "Now Tap Me, For Glory!" label is clicked
*/
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let input = UITextField()
input.placeholder = "Tap here first -- to bring up keyboard"
input.frame = CGRect(x: 10, y: 50, width: 300, height: 20)
view.addSubview(input)
let button = UIButton()
button.setTitleColor(UIColor.blue, for: .normal)
button.setTitle("Then tap here", for: .normal)
button.addTarget(self,
action: #selector(buttonPushed),
for: .touchUpInside)
button.frame = CGRect(x: 10, y: 80, width: 200, height: 20)
view.addSubview(button)
}
func buttonPushed() {
let modalVC = ModalViewController()
present(modalVC, animated: true, completion: nil)
}
}
class ModalViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.white
let label = UILabel()
label.text = "Now Tap Me, For Glory!"
label.frame = CGRect(x: 10, y: 50, width: 300, height: 20)
view.addSubview(label)
label.isUserInteractionEnabled = true
label.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(labelTapped)))
}
func labelTapped() {
UIApplication.shared.open(URL(string: "http://planetbeagle.com")!, options: [:], completionHandler: { _ in
self.dismiss(animated: true, completion: nil) })
}
}