I got the same issue here
The UIScrollView can scroll when adding button or label via code, but failed when adding from the storyboard or xib.
Setting the contentSize from the viewDidAppear can resolve this issue.
Set up the contentSize from viewDidLoad can not work. Question here is to figure out why ? I hope someone can explain the insider magics or this is just a bug of UIScrollView. I think it should not be designer like this way.
The reason it doesn't work in
ViewDidLoad
is that all the sizes are not yet final there, in fact, Im betting it would also not work inviewWillAppear
.Im guessing you are not liking making the change inviewDidAppear
as it is visible to the user. The correct place to set the size isviewWillLayoutSubviews
. The flow isI suggest you reread those methods in the documentation.