Removing view from its superview

后端 未结 3 910
臣服心动
臣服心动 2021-01-25 12:09

I have added a few buttons to self.view. When the user clicks on one button, i will load another view (subView). My code where i am loading the subView is shown below

         


        
3条回答
  •  太阳男子
    2021-01-25 12:34

    Try removing the subview like this:

    for (UIView *subView in self.view.subviews) {
        if (subView.tag == (int)yourSubViewTag) {
    
            [subView removeFromSuperview];
        }
    }
    

提交回复
热议问题