AtelierClockwork

Graceful UI Locking

November 27, 2015

Finding Durable Solutions to Problems

In the iOS developer world, one of the mantras that developers are taught early is “never block the main thread.” Part of this is keeping the system happy, but it also is trying to keep the UI responsive at all times.

And most of the time, a lot of effort goes into making the app always be responsive to the user. Then there’s the handful of situations where an action is in flight that the user needs to wait for completion, and it may take 1/60th of a second, or it may take 10 seconds.

This means the interface needs to temporarily stop responding, and possibly show a cancel button, but in a way that gracefully deals with both the short and long cases. The next requirement is making it so that the lock and unlock behavior don’t require a lot of effort to add to an existing view controller.

Right now my preferred method is a heavily customized presentation animation, and clever use of animation delays and options. To really make it behave well, want figure out clean way of using closures to specify the work that will lock the screen, and what to do when the screen lock is released.