Geoff Pado

Black Highlighter — April 27th, 2019

This session is all about struggling with the weird behaviors of UIScrollView and Auto Layout. At the end of the previous session, I had displayed the text observations, but they weren’t scaled appropriately with the image that they were associated with. To make this work, I needed to put both the image view and the visualization view inside a scroll view, which would zoom out and display the whole image at a time.

This didn’t go as easily as planned, though; while I was able to pretty quickly determine the scale which I needed to zoom the image to, setting the zoom scale didn’t actually appear to be doing anything. Eventually, I discovered that I needed to implement the scroll view delegate method viewForZooming(in:), which returns the editing view.

However, after implementing this, the view no longer scrolled. After some digging with the view debugger, I discovered that the editing view was completely zero-sized: 0 width, 0 height. After several attempts to fix that behavior, I remembered the obvious fix: the editing view needed translatesAutoresizingMaskIntoConstraints set to false.

That’s the way developing apps is sometimes: bang your head against a seemingly-intractable problem for a long period of time, then realize it only requires a simple fix. 🤦‍♂️

Commits Made

Tickets Closed

Tickets Created

Project Stats

Sessions Completed
9
Days Since Start
27
Issues Closed
10
Issues Open
24
Percent Complete
29.4%

Replay

Coming soon.