cdzombak/strikescope — pull request #1 by andrewsardone (2012-07-16 19:50:03+00:00)
Title: Fix crash due to `CALayerInvalidGeometry` exception

When launching the app on an iPad in landscape orientation, it crashes due to the following uncaught exception:

'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'

The troublesome code looks to be sending the `-[UIScrollView setZoomScale]` message to the `imageScrollView` in `SSSViewController`. What this uncaught exception leads me to believe is that setting the zoom scale has some side effect on some other internal `UIView`/`UIScrollView` property, but that property (or one of its dependencies) is currently a junk piece of data (see `NaN`).

It's interesting that at the moment of the crash, the device's orientation is `UIDeviceOrientationUnknown`. There must be something fishy going on with properly initializing views and their orientation. Guarding against setting the zoom scale when in an unknown orientation seemingly prevents the crash, but I don't know what other implications this has.

This isn't a sufficient patch to the problem, i.e., this pull request shouldn't be merged upstream, but it can act as an initial clue/discussion point.