Remove all subviews?

前端 未结 15 1728

When my app gets back to its root view controller, in the viewDidAppear: method I need to remove all subviews.

How can I do this?

15条回答
  •  时光说笑
    2020-11-28 00:49

    In objective-C, go ahead and create a category method off of the UIView class.

    - (void)removeAllSubviews
    {
        for (UIView *subview in self.subviews)
            [subview removeFromSuperview];
    }
    

提交回复
热议问题