PushViewController 不起作用 - deinit 调用



从第一个控制器,我尝试切换视图控制器:

let player = self.storyboard?.instantiateViewControllerWithIdentifier("WK_player") as? WKViewController
self.navigationController?.pushViewController(player!, animated: true)

但WKView控制器没有出现,直接打电话给他的deinit。

它与

performSegueWithIdentifier("WK_Play", sender: nil)

但是有了这个,当我关闭播放器并保持内存中存在时,永远不会调用 dealloc。

dismissViewControllerAnimated(true, completion: nil)

问题出在哪里?

内存

泄漏的问题不是performSegueWithIdentifier("WK_Play", sender: nil)。问题可能是您在 VC 中的某处有一个强引用WK_Play该引用未被删除,因此无法解除分配 VC。

您也可以尝试演示,但我敢打赌内存泄漏仍然存在:

let player = self.storyboard?.instantiateViewControllerWithIdentifier("WK_player") as? WKViewController
self.presentViewController(player, animated: true, completion: nil)

最新更新