控制器和视图的发布
如果我有一组在高级应用程序“重新启动”例程中释放的自定义 UIViewController,那么释放其视图的好方法是
self.view = nil;
在 dealloc 方法中设置吗?
If I have a set of custom UIViewControllers that I release in a high level application "restart" routine, would a good way to release their views be to set
self.view = nil;
in the dealloc method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定你的视图在哪里,但你通常会想从超级视图中删除它们(如果有的话),
如果它被超级视图以外的其他东西保留,你会想释放它,
假设你的retainCount为0 , dealloc 将会被调用(在 99% 的情况下,你永远不应该自己调用 dealloc),
那么是的,你会想要将它归零。
然后你就可以重新创建你的观点或任何你想做的事情。
I'm not sure where your views are, but you usually would want to remove them from superview (if they have one)
if it's retained by something else other than its superview, you'd want to release it
assuming your retainCount is then 0, dealloc will be called (in 99% of the cases, you should never call dealloc yourself)
then yes, you would want to nil it.
then you can recreate your views or whatever you want to do.