Hi All,

I'm trying to setup a scroll for a UIView within a UIScrollView.

My view hierarchy is:

UIView (Controller) > UIScrollView > UIView (I'll call this subView from this point on)

I have used the IB to set the layout. I set the top of the subView to be inline with the top of the UIScrollView frame. The subView is as wide as the UIScrollView frame and extends beyond the height of the UIScrollView frame.

In the subView I have UILabels (also set up using the IB). To test the scrolling, I have one label that is just peeking above the bottom border of the UIScrollView frame. When I run the app this label would ideally be able to scroll into view, however, there is no scrolling and the label is just appearing as being cut off where the UIScrollView frame ends.

In the ViewController.m I have the following:

- (void)viewDidLoad
    self.scrollView.contentSize = self.scrollSubView.frame.size;

where scrollSubView is the UIView within the UIScrollView.

What am I missing (doing incorrectly) that is preventing the scroll from working?

Thanks for any assistance offered.

2 Years
Discussion Span
Last Post by hericles

you should have the scrollview size set as less than the content size i.e. the currently viewable area and the content size set to the full area the scrollview should hold. It sounds like you have that right.
UserInteractionEnabled is on for the scrollview right?
One other issue is that if your subview fills the available area of the scrollview, subview is detecting the swipe action not the scrollview. You can test that by shrinking the width of the subview to give yourself a margin that should respond to the scrollview.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.