从 UIView 中删除 UIViewController 并释放内存
我使用以下方法在另一个 UIView 中添加 UIViewController:
self.addChild(vc)
self.view.addSubview(vc.view)
vc.didMove(toParent: self)
并通过以下方式删除该 UIViewController:
for childVC in self.children {
childVC.willMove(toParent: nil)
childVC.view.removeFromSuperview()
childVC.removeFromParent()
}
UIViewController 从视图中删除,但该 UIViewController 的 deinit 未调用,并且不会释放该 UIViewController 的内存。
我没有为它分配任何可能导致强引用循环的委托,我还需要记住什么才能从内存中释放它?还有其他办法吗?
I'm adding UIViewController in another UIView using:
self.addChild(vc)
self.view.addSubview(vc.view)
vc.didMove(toParent: self)
and removing that UIViewController by:
for childVC in self.children {
childVC.willMove(toParent: nil)
childVC.view.removeFromSuperview()
childVC.removeFromParent()
}
UIViewController remove from view but deinit of that UIViewController is not calling and it does not release memory of that UIViewController.
I'm not assigning any delegate to it that might cause strong reference cycle, what other thing I've to keep in mind to release it from memory too? Any other way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论