Search code examples
iosuiscrollviewsubviews

UIScrollView is not scrolling the content of another subview


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!


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