简体   繁体   中英

PushViewController doesn't work - deinit called

From firstController,I try to switch viewController :

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

But WKViewController doesn't appears and directly call his deinit.

It's work well with

performSegueWithIdentifier("WK_Play", sender: nil)

But with this, dealloc is never get called when I close player and keep existing in memory.

dismissViewControllerAnimated(true, completion: nil)

What is the problem ?

The issue for the memory leak isn't performSegueWithIdentifier("WK_Play", sender: nil) . The issue is probably that you have a strong reference somewhere in WK_Play VC which isn't removed thus the VC can't get deallocated.

You could also just try presenting with, but I bet the memory leaks will remain:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM