How To Center Content Within UIScrollView

1 · Peter Steinberger · Feb. 21, 2013, 11:07 a.m.
There seems to be some confusion around the net when it comes to the best way to center a view within an UIScrollView. And it’s actually not that easy to get right. In PSPDFKit version 1, I used the Apple-recommended way (see Apple’s photo example) of subclassing layoutSubviews. This was “good enough” until I added smart zoom in version 2 of my PDF framework. (That is, text blocks are detected and zoomed onto with a double tap, just like you’re used to in the mobile version of Safari). I noticed...