Basically, I want to remove all objects from UIScrollView, and I have not yet found a solution for it, because the simple "removeAllObjects" command does not work. Does anyone have an idea how to do this?
Even simpler:
[[scrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
The easiest way:
for(UIView *subview in [scrollView subviews]) { [subview removeFromSuperview]; }
:
#define XPScrollViewSubviewStartTag 100
for(NSInteger = 0;i<[viewArray count];i++){ UIView* view = [viewArray objectAtIndex:i]; view.tag = XPScrollViewSubviewStartTag + i; [scrollView addSubview:view]; }
,
for(UIView* view in [scrollView subviews]){ if(view.tag >= XPScrollViewSubviewStartTag) [view removeFromSuperview]; }
for(id view in [scrollView subviews]){ if(![view isKindOfClass:[CustomView class]]) continue; //not necessary, but just to make things understandable CustomView* customView = (CustomView*)view; [customView removeFromSuperview]; }
Oritm , , , scrollview. , , . , scrollview UILabels, , :
// This will remove the scrollview but the scrollbars will remain for (UIView *subview in [self.detailsExpander.scrollView subviews]) { if ([NSStringFromClass([subview class]) isEqualToString:@"UILabel"]) [subview removeFromSuperview]; }
, ( ). . , , , .