I spent hours trying to get scrollview to work with autolayout. I did some good research, and read these great articles
http://natashatherobot.com/ios-autolayout-scrollview/ http://spin.atomicobject.com/2014/03/05/uiscrollview-autolayout-ios/
And I think i set up everything properly but my problem is, in my vertically scrollable scrollview, I am setting the content height explicitly to 800, but the width of the container inside has about 32 pixels cut off from the right edge. The green background is scrollview, so it fills the view correctly, but somehow either the width of the contentView is not enforced, or scrollView has some sort of insets. And the debugger says neither is the case.
You can see all the constraints in the screenshot. The content view also has a height constraint of 800 which is not expanded in the picture below...
Also interestingly when I pinned edges of scroll to the outer view, the trailing and leading alignments are set to -16 each. And not sure if this is causing the 30+ pixels problem I am having...
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
self.contentView.frame = CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, self.contentView.frame.height)
scrollView.frame = self.view.frame
scrollView.contentInset = UIEdgeInsetsZero
scrollView.contentOffset = CGPointZero
scrollView.contentSize = CGSizeMake(320, 800)
}
Here is the problem images and constraints