Search code examples
uiscrollviewios7xcode5

Xcode 5 iOS 7 - UIScrollView behaving oddly


When migrating a project from Xcode 4 iOS 6, I noticed the UIScrollView instance is not behaving properly. Sometimes it just seems to be stuck, and only when I pinch in or out to change the scale does it start scrolling properly.

I noticed a few replies in a similar question, along the lines of removing positioning constraints, that I tried (even though I do need the constraints eventually) and it didn't work.

Has anyone encountered this behaviour and found a way to fix it?


Solution

  • Ensure setContentSize is in viewDidLayoutSubviews and in scrollViewDidEndZooming:withView:atScale:. In iOS6, if you didn't call setContentSize in these methods, the default behaviour worked okay, in iOS7 with the new layout system, they are required. viewDidLayoutSubviews may be called more than once for a setup, just keep calling setContentSize.