ios - 打开 UIImagePicker 后如何在 AR Kit 场景中保留节点
问题描述
当我之前添加的所有节点(例如)文本在打开照片库或相机以添加新的照片节点后消失时,我遇到了一个问题。有什么办法可以解决吗?我的警报代码:
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "Add Text", style: .default , handler:{ (UIAlertAction) in
self.addTextView.isHidden = false
self.inputTextField.becomeFirstResponder()
}))
alert.addAction(UIAlertAction(title: "Choose from Library", style: .default , handler:{ (UIAlertAction) in
alert.dismiss(animated: true, completion: nil)
let picker = UIImagePickerController ()
picker.delegate = self
picker.allowsEditing = true
picker.sourceType = UIImagePickerControllerSourceType.photoLibrary
self.present (picker, animated: true , completion: nil)
}))
alert.addAction(UIAlertAction(title: "Take a Photo", style: .default , handler:{ (UIAlertAction) in
alert.dismiss(animated: true, completion: nil)
let picker = UIImagePickerController ()
picker.delegate = self
picker.allowsEditing = true
picker.sourceType = UIImagePickerControllerSourceType.camera
self.present (picker, animated: true , completion: nil)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler:{ (UIAlertAction) in
// ACTION
}))
self.present(alert, animated: true, completion: nil)
解决方案
您的问题不在于您的警报,而在于您正在呈现另一个视图 - 离开 AR 场景。
这没关系,但是当您返回视图时,您的 AR 场景可能会被重新加载,可能是通过 viewWillAppear 中调用的东西或类似的东西。
检查一下,如果不是这样,请从您的生命周期覆盖(viewDidLoad、viewDidAppear、viewWillAppear)中发布代码 - 因为显示警报不会导致此错误。
推荐阅读
- r - 使用 crrri 包和无头 chrome 向下滚动页面
- erlang - 为什么 Pry shell 在 Phoenix/cowboy 中超时如此之快?(shell进程退出原因:关机)
- javascript - javascript递归方法?
- r - 更改设计矩阵 model.matrix 的基础/参考
- java - 如何在 maven:3.6.3-openjdk-8 中下载 microdnf?
- php - 每天创建一个新行来计算页面浏览量
- python - 如何阻止我的函数每次运行前 3 行?
- lua - LUA用gsub删除2个不同的字符
- r - R如何使用%>%“即时”订购DF?
- python - 带有中断超时的输入