打开UIImagePicker后如何在AR Kit场景上保留节点

时间:2018-05-16 17:36:15

标签: ios swift arkit

在打开照片库或相机添加新照片节点后,我以前添加的所有节点(例如)文本消失时,我遇到了问题。有什么办法可以解决吗? 我的提醒代码:

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)

1 个答案:

答案 0 :(得分:0)

您的问题不在于您的警报,而在于您正在展示另一个视图 - 离开AR场景。

这没关系,但是当你返回到视图时,你的AR场景可能会被重新加载,可能是在viewWillAppear中调用的东西或类似东西。

检查一下,如果不是这样,请发布生命周期覆盖中的代码(viewDidLoad,viewDidAppear,viewWillAppear) - 因为提示警报不会导致此错误。