Remove all subviews?

前端 未结 15 1699

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:51

    In order to remove all subviews from superviews:

    NSArray *oSubView = [self subviews];
    for(int iCount = 0; iCount < [oSubView count]; iCount++)
    {
        id object = [oSubView objectAtIndex:iCount];
        [object removeFromSuperview];
        iCount--;
    }
    

提交回复
热议问题