iOS 12 scrollview zoom broken?

Anyone else seeing bad behaviour on zooming UIScrollViews in the first iOS 12 beta?


I've got a minimal app with a scrollview containing an imageview, set up using autolayout as you'd expect - imageview constrained to the scrollview, scrollview constrained to the view-controller's view. The scrollview's delegate returns the imageview from viewForZooming .


On iOS 11 it behaves as you'd expect, but on iOS 12 the imageview is offset by some amount proportional to the zoomScale, as if it had a contentInset (it doesn't)


Filed it as rdar://40799147 , but it seems like an obvious enough problem that I'm wondering if I'm doing something dumb.


Edit: More specifically, it looks like the viewForZooming's center is bad. Previously the scrollview would this scale up and down with the zoomScale, whereas on iOS 12 it is fixed to the view bounds center. Since a view's center is in the superview coordinate space (in which the view has been scaled), this seems wrong.


Edit2: Come to think of it, I don't understand how zooming scrollviews ever actually worked with autolayout. It seems like the iOS 11 behaviour actually only works by silently breaking a bunch of constraints when you zoom in or out - when you zoom, nothing changes that autolayout cares about (only transforms and frames are changed) but it still somehow comes up with a different answer for your view's center. Whereas the iOS 12 behaviour seems like autolayout behaving as-advertised.


I don't get why this change doesn't break more apps than it does...

All scrollviews with zooming and contraints that I have on several apps are broken now too.

I'm seeing the same problem in my app, it's really weird. However there are other apps that somehow seem not to be affected, not to mention Apple's Photos.app which I assume is using UIScrollViews with UIImageViews embedded and is not showing the same issue :/

Saw the same symptoms when running an app where scrolling worked fine in previous versions of the OS.


I fixed it by returning the image view itself in the viewForZooming(in:) delegate method.

Instead of returning the wrapper view that I had put around the image, I now have this function return the imageView itself.


func viewForZooming(in scrollView: UIScrollView) -> UIView? {
    if #available(iOS 12.0, *) {
        return self.imageView
    } else {
        return self.wrapperView
    }
}


Works for me as expected. Not sure why, but I thought I’d share it.

Oh wow, this sounded so promising, especially as I am also using a wrapper view in my app. Unfortunately though, even returning the underlying UIImageView made no difference in my case 😟

I have a github repo that demonstrates the problem. Unfortunately I cannot post the link here because of the draconian moderation filter :/


My GH username is "mluisbrown" and the repo is called "ZoomTest" if you can reach it that way...


From Xcode 10, if you run it in iOS 11.4 simulator it works as expected. In iOS 12 simulator it's completely broken. And viewForZooming is returning the imageView directly (there is no wrapper view)

Created another Radar: rdar://41125342

This breaks my app too so I filed a bug rdar://41264586 and referenced the above two bug reports that were already filed. I'm still noticing the issue in beta 2.

Yep. Still noticing the issue in beta 2 allthough it seems to be slightly better, the offset of the scaled image is not as huge as it was before. In my app the image is now visible, if offset to the right and bottom, whereas in beta 1 it was just not even on the screen.

Ok, my Radar has been marked as a dupe of rdar://40799147 which is the one klassobanieras created.

I have the same issue in my apps, works just fine in iOS 11.4. Same issue on real device running iOS 12 beta 2 (iPhone 7).

For what it's worth, running the Xcode 9 / iOS 10 build on an iOS 12 beta (1 or 2) device also goes wrong. So you don't even have to opt in to iOS 12 behaviour (by building with Xcode 10) to have problems. Here's hoping it's fixed in beta 3...

I wish I would have been smart enough to check into this before spending an hour and a half trying to figure out how I broke this in my app during a refactor this evening...

Yep, I started spotting it in live (ie. built for iOS 11) apps too, notably Signal.

This did not work for me. We are not using any wrapperView anyways

This is fixed for me in beta 3 (didn't even have to rebuild my app).

iOS 12 scrollview zoom broken?
 
 
Q