Reputation: 6940
I have controller with UIScrollView in it, and in iPad version there is no scrolling from up to bottow. I explicitly set content size height like that:
CGSize newSize = CGSizeMake(self.view.bounds.size.width-4, 2500);
// assume self is the content view
CGRect newFrame = (CGRect){CGPointZero,newSize}; // Assuming you want to start at the top-left corner of the scroll view. Change CGPointZero as appropriate
[self.mainScroll setContentSize:newSize];
Even in debugger, when i print description of scrollView
i see following:
<UIScrollView: 0x7fc12486e400; frame = (0 0; 768 960); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x7fc1259cf830>; layer = <CALayer: 0x7fc1259a45e0>; contentOffset: {0, 765}; contentSize: {764, 2500}>
(lldb)
As you can see, content size is set to 2500, however, i cant scroll anything. And i obviously check, that scrolling enabled is YES..
Also, main scroll view is bound to main view with constraints like top-left-right-bottom with value of 0. But, even when i increase height of self view, still, no effect.
How to force it to scroll??
Upvotes: 1
Views: 179
Reputation: 534925
The problem is that you're using auto layout. An attempt to set, in code, the contentSize
of a scroll view under auto layout will fail. Scroll view content size under auto layout works in a completely different way: you use as the scroll view's sole immediate subview a container view, sized by internal constraints to the content size and pinned on all four sides to the scroll view with a constant
of zero.
Upvotes: 3