如何在打开 UIImagePicker 后将节点保留在 AR Kit Scene 上
How to keep nodes on AR Kit Scene after opening UIImagePicker
打开照片库或相机添加新的照片节点后,我之前添加的所有节点(例如)文本都消失了,我遇到了一个问题。有什么办法可以解决吗?
我的提醒代码:
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 场景。
没关系,但是当您 return 进入视图时,您的 AR 场景可能会被重新加载,可能是通过 viewWillAppear 中调用的东西或类似的东西。
检查一下,如果不是这样,请post生命周期中的代码覆盖(viewDidLoad、viewDidAppear、viewWillAppear)- 因为显示警报不会导致此错误。
打开照片库或相机添加新的照片节点后,我之前添加的所有节点(例如)文本都消失了,我遇到了一个问题。有什么办法可以解决吗? 我的提醒代码:
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 场景。
没关系,但是当您 return 进入视图时,您的 AR 场景可能会被重新加载,可能是通过 viewWillAppear 中调用的东西或类似的东西。
检查一下,如果不是这样,请post生命周期中的代码覆盖(viewDidLoad、viewDidAppear、viewWillAppear)- 因为显示警报不会导致此错误。