Yimin Rong
Yimin Rong

Reputation: 2027

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?

Upvotes: 8

Views: 3929

Answers (2)

user2191247
user2191247

Reputation:

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.

Upvotes: 0

Lv.BeLeCk
Lv.BeLeCk

Reputation: 420

I was able to make it work by using

self.automaticallyAdjustsScrollViewInsets = NO;

in the view controller holding the scrollview. Just put it after the scroll view's instantiation.

Upvotes: 16

Related Questions