Does UIView's removeFromSuperView method remov

2020-05-25 08:15发布

Does UIView's removeFromSuperView method remove the UIView from memory? I just want to be sure that the view is no longer using any memory?

2条回答
做自己的国王
2楼-- · 2020-05-25 08:24

UIView retains its subviews, so when you call -removeFromSuperview method then your view object is released.

So if everything else is ok with your memory management and your view is not retained by anything else then yes - your view should be deallocated and removed from memory.

Possible example when simply removing view from superview may not be sufficient to deallocate it can be view that has outlet connection and declared property for it with retain attribute - in that case it is retained by controller when it is being loaded from nib file and you may need to release that view for that case:

[iVarView removeFromSuperview];
self.iVarView = nil;
查看更多
一纸荒年 Trace。
3楼-- · 2020-05-25 08:41

Yes. Once removeFromSuperView method is called, that view is also released from memory.

If you want to confirm with Apple's documentation, here is the link.

查看更多
登录 后发表回答