Swift UIScrollView not scrolling but responding to setContentOffset and Delegate responds

ios, swift, uiscrollview

Solution

It isn't scrolling with drag gestures because of auto layout. In viewDidLoad, auto layout will reset the content size after you define it. You have two options: you can disable auto layout, or you can set contentSize in viewDidLayoutSubviews.

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    scrollView.contentSize = CGSize(width:10, height:10)
}

Problem

Getting a really bizarre incident with a `UIScrollView` here which just refuses to scroll. I set it up in my StoryBoard and set the `contentSize` correctly in my `ViewDidLoad`. I double checked to ensure that it was `Scrollable` etc, yet it's just not working. I set `scrollView.setContentOffset()` and it scrolls fine with a lovely animation and the `ScrollViewDidScroll` delegate get's called. So, with that said any reason why it may not be scrolling with drag gestures? Things I've checked: - `UserInteraction` Enabled on itself, all `sub/superviews`. - `Scrollable`. - Toggled: `DelaysContentTouches` and `CancellableContentTouches`. I'm out of ideas. Currently using `Xcode 6 Beta 1`. Any help would be appreciated. Regards, Mike

Original source