NSArray *subviewsList = [[NSArray alloc] initWithArray:[self.view subviews]];
for (UIView *aView in subviewsList) {
NSLog(@"%@",subviewsList);
if (![aView isEqual:sender]) {
[aView removeFromSuperview];
}
}
[subviewsList release];
I have it not remove the UIButton that you click to actually call this code, however, I haven’t figured out how to get it not to remove the UIToolbar that I added to the screen via IB. Any suggestions?
EDIT: I should have been more clear, I’m sorry. The code was done to remove the ton of UIImageViews from the screen. I didn’t want it to remove the uibutton that calls the method, or the toolbar.
EDIT:
This works. 🙂
if (![aView isEqual:sender] && ![aView isKindOfClass:[UIToolbar class]]) {
Send from iphone, maybe syntax errors 🙂 but this let you check if your subview is from a specific class
Hope this helps