![](/img/trans.png)
[英]Does using `self.navigationController?.popViewController(animated: true)` dismiss the current ViewController or just return to the previous?
[英]navigationController?.popViewController(animated: true) doesn't deinit the view controller
當我使用navigationController?.popViewController(animated: true)
或關閉UINavigationController
,不會調用ViewController
的deinit
方法。 這是否意味着它們沒有在內存中被釋放?
如何取消分配UINavigationController
及其所有ViewController
?
如上所述,您可能在某個變量中保存了對視圖控制器的引用。 如果是這種情況,則該變量會導致Swift將您的View Controller保留在內存中。 您可以做一些事情來解決該問題:
weak var
變量weak var
,這意味着,如果該變量的最后一個變量保留對某物的引用,則將其釋放。 詳盡的注釋將有望幫助您找到有問題的變量。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.