Question

Hi everyone. I dragged a UIScrollView to my storyboard, then I added a UIView on top of that UIScrollView. This UIView loads another subview dynamically depending on what the server throws to this app.

The problem is the UIScrollView is not scrolling the content, even though I made the loaded UIView bigger than the UIScrollView. I'm not invoking [myScroller addSubView:myUiView]. Am I doing it right? Thanks in advance!

Was it helpful?

Solution

For every time you change the content try calling

//removeFromSuperview the UIView was set as content view
self.myScroller.contentSize = self.myUiView.frame.size;
[myScroller addSubView:myUiView];

Don't forget to link both views on Interface Builder

PS: In this apporach the subView must not be inside the scrollView on IB

OTHER TIPS

You must set the content size of the scroll view.

Add this in your view controller.

- (void) viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];

    myScroller.contentSize = CGSizeMake(CGRectGetMaxX(myUiView.frame), CGRectGetMaxY(myUiView.frame));
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top