简体   繁体   中英

How to remove all the subviews and the nesting of the a view while removing the a UIView from superview?

I am developing a simple UI control. The data source can be any one. UI Control I develop will receive any thing derived from UIVIew using the data source methods and will add in its view.

Now I will be able to track all the UIViews I receive from the data source using a collection. When I use the below statement, all the views will be removed from the superview.

 [gridCells makeObjectsPerformSelector:@selector(removeFromSuperview)];

What will happen to all the views that were added on the views created and added on the view returned through the data source methods?

You can iterate through all the subviews of superview like this.

 for (UIView *subview in self.view)
  {
     [subview removeFromSuperview];
  }

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