Code Code - 1 year ago 64
iOS Question

What is the best way to remove all subviews from you self.view?

I was thinking maybe something like this might work:

for (UIView* b in self.view.subviews)
[b removeFromSuperview];

I want to remove every kind of subview. UIImages, Buttons, Textfields etc.

Max Max
Answer Source
[self.view.subviews makeObjectsPerformSelector: @selector(removeFromSuperview)];

It's identical to your variant, but slightly shorter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download