Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all buttons from a view in iOS 7?

How can I remove all buttons from a view using iOS 7?

Here's code that works in earlier versions of iOS:

                for(UIView *view in cell.subviews){
                    if([view isMemberOfClass:[UIButton class]]){
                        [(UIButton *)view removeFromSuperview];
                    }
                }
like image 791
GVA Avatar asked Dec 03 '25 04:12

GVA


1 Answers

First you need to get all subviews from view and then check all view is type of UIButton.For more info see this...

for (UIView *view in self.view.subviews)
    {
        if ([view isMemberOfClass:[UIButton class]])
        {
            [(UIButton *)view removeFromSuperview];
        }
    }
like image 110
Dharmbir Singh Avatar answered Dec 04 '25 18:12

Dharmbir Singh