【问题标题】:How to keep nodes on AR Kit Scene after opening UIImagePicker打开 UIImagePicker 后如何在 AR Kit 场景中保留节点
【发布时间】:2018-05-17 01:42:26
【问题描述】:

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

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)

【问题讨论】:

    标签: ios swift arkit


    【解决方案1】:

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

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

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

    【讨论】:

    • 谢谢。我从 didAppear() 中删除了会话恢复并将其仅插入到 viewDidLoad() 中。这杀死了我的“拍照”,因为在相机会话后会话无法获得位置。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多