解雇ViewController时ARSKView不会释放内存

时间:2018-06-30 17:36:57

标签: ios swift sprite-kit scenekit arkit

我正在创建一个使用ARSKView的应用程序。我看到它不解雇ViewController释放内存。我在代码中找不到任何问题。 这是我使用ARSKView的代码。

class ARViewController: UIViewController, ARSKViewDelegate {

    weak var sceneView: ARSKView?

    override func viewDidLoad() {
        super.viewDidLoad()
        sceneView = ARSKView(frame: self.view.frame)
        self.view.addSubview(sceneView!)
        sceneView?.delegate = self

        let scene = CustomScene(size: view.frame.size)
        scene.sceneDelegate = self
        sceneView?.presentScene(scene)
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        activateARView()   
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        sceneView?.session.pause()
    }

    var configuration = ARWorldTrackingConfiguration()
    func activateARView() {
        configuration.worldAlignment = .gravityAndHeading
        sceneView?.session.run(configuration)
    }

}

1 个答案:

答案 0 :(得分:0)

控制器刚刚暂停,您可以尝试将控制器设置为“ nil”,以确保在此之前清除所有依赖项。