Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove all objects from a uiview?

Tags:

iphone

uiview

I have a UIview which I am drawing a series of buttons on to. I want to change these buttons depending on a selection the user makes. This is working nicely... but I cannot remove the buttons which were already there.

It's a UIScrollView with a view added as a subview. It's the subview which I need to basically "clear" / wipe clean. In Interface builder there is nothing on that view. I simply add it in my code.

I've been looking around and have looked at doing subViewcontroller setNeedsDisplay, but nothing's working.

any ideas? thanks for any help.

like image 748
Matt Facer Avatar asked Jan 11 '10 21:01

Matt Facer


1 Answers

I've actually figured out how to do what I needed... but I'd still be keen to see what people suggested.

I wanted to remove all the buttons in my view which was assigned to the UIScrollView. I KNOW they are only buttons being added, so I just looped through them all removing them one by one.

for (UIButton *aButton in [viewBasicItems subviews]) {
    [aButton removeFromSuperview];
}
like image 152
Matt Facer Avatar answered Sep 19 '22 12:09

Matt Facer