DaSilva
DaSilva

Reputation: 1358

Resize UIScrollView

I am creating an app like the "PageControl" from apple. An scrollview with another scrollview inside for each page.

UIScrollView * scrollForPage = [[UIScrollView alloc]init];  
    scrollForPage.pagingEnabled = NO;
    scrollForPage.contentSize = CGSizeMake(mainScroll.frame.size.width, 200 + mainScroll.frame.size.height+150);
    scrollForPage.autoresizingMask =  ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    scrollForPage.clipsToBounds = YES;

    CGRect frame = mainScroll.frame;
    frame.origin.x = frame.size.width * page;
    frame.origin.y = 0;

    CGRect frame2 = frame;
    frame2.origin.x = 0;
    frame2.origin.y = 0;

    controller.view.frame = frame2;
    scrollForPage.frame = frame;


    [scrollForPage addSubview:controller.view];

    [mainScroll addSubview:scrollForPage];
    [scrollForPage release];

however my controller´s view have an dynamic size, how can I resize the "scrollForPage" to have the same size??

Thanks

Upvotes: 0

Views: 830

Answers (1)

Jack Humphries
Jack Humphries

Reputation: 13267

The code to detect the size of a view is this:

CGRect screenSize = [[UIScreen mainScreen] bounds];

Just make the frame of the scroll view equal to screenSize, and call the above line often.

Upvotes: 1

Related Questions