I'm new to Storyboards; I've done some Interface Builder before and lots of manual UI positioning. I've searched this issue, tried the solutions found in the other relevant posts, to no avail.
I have a view controller with a UIScrollView added in Storyboards. The ScrollView outlet has been connected, the property synthesized. Scrolling Enabled is checked. Bounces is checked. Even then there was no indication that any scrolling would take place. When I checked Bounces Vertically, I could at least see the scrollable content, but it bounces back after I release. The frame size I found set at 320 and 521. I experimented with different heights but nothing helped. (What ought to be the size set in Storyboards that will accommodate the older and newer phone sizes?).
In viewDidLoad, I added
[scrollView setContentSize:CGSizeMake(320, 1000)];
A log statement afterwards confirms that this value has been accepted. But it didn't help either.
Someone in one post suggested adding:
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[self.scrollView setContentSize:CGSizeMake(320, 808)];
}
This had the effect of crashing the program when the controller loaded.
Any help would be greatly appreciated!
Thanks.
Two things turned out to be necessary:
1) Set height of scrollview to 480.
2) Add constraint to the bottommost field in the scrollview. The constraint was Pin >> Bottom Space to Superview.
Just add the following method:
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[self.scrollView setContentSize:CGSizeMake(320, 1700)];
}
This is working perfectly for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With