lakshmen
lakshmen

Reputation: 29074

Reducing the size of scrollview after removing subviews from scrollview in iOS

I want to remove subviews from scrollview, and saw this post: how to remove subviews from scrollview?

I am using this code to remove the subviews:

NSArray *subviews = [[scroller subviews] copy];
for (UIView *subview in subviews) {
    [subview removeFromSuperview];
}

But I need to reduce the size of the scrollview?

How do I do that?

This is how I am removing a particular view:

        NSArray *subviews = [[menuScrollView subviews] copy];

        for (UIView *subview in subviews)
        {
            NSLog(@"subview.name is %i",subview.tag);
            if(subview.tag == 1001)
            {
                [subview removeFromSuperview];
                break;
            }

        }

EDIT:

I tried this:

[mScrollView setContentSize:CGSizeMake(mScrollView.frame.size.width,mScrollView.frame.size.height-subview.frame.size.height)];

But it is still not working...

Upvotes: 0

Views: 391

Answers (1)

Pratik
Pratik

Reputation: 2399

try below code

[[scrollVw subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

you will be succeed

Upvotes: 2

Related Questions