Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove the content in a UIScrollView Programmatically?

How do you remove the content in a UIScrollView Programmatically? As I have to update the content in it frequently.

like image 857
Popeye Avatar asked Nov 30 '22 15:11

Popeye


2 Answers

I don't think that there is a difference between typical UIView:

for (UIView *v in [scrollView subviews])
    [v removeFromSuperView];
like image 172
beryllium Avatar answered Dec 21 '22 14:12

beryllium


You can loop through your scroll view's subviews like:

for(UIView *subview in scrollView.subviews)
    [subview removeFromSuperview];

or you can use - [NSArray makeObjectsPerformSelector:] method like:

[scrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
like image 28
neilvillareal Avatar answered Dec 21 '22 15:12

neilvillareal