Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

whitedragon101

macrumors 65816
Original poster
Sep 11, 2008
1,349
339
I have a viewcontroller that contains a view which contains a scrollview which contains my content i.e

ViewController:
- View > ScrollView -> text feild

This is so when I tap in the text field the content moves up and the keyboard doesn't cover the text field.

Now I come to use autolayout I add constraints for the scrollview for 0,0,0,0 for leading, trailing (to container), top, bottom (to top bottom layout guide). It duly fills the screen on a 3.5" or 4" screen. So for so good.

The problem comes when add a constraint for the text field to 5px for "bottom space to container." It does nothing. I would be grateful for any help to lay out objects in the scrollview.
 
This could be because the scrollview has no intrinsic contentSize. I usually set up my scrollviews programmatically, and therefore do something like

Code:
_scrollView.contentSize = CGSizeMake(500, 500)

If the scrollView has no contentSize set yet, it doesn't know the size of all of the stuff that it contains (because a UIScrollView can contain stuff larger than its own bounds).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.