Dropdown Alerts

Although the iOS UIAlertView class is really handy for drawing a user’s attention to an issue with an application, it can be too intrusive and disruptive if used excessively, because it grabs focus and dumps its message (plus optional input) in the centre of the screen. Whilst this is okay for severe messages, most informational or temporal messages could be dealt with a lot more smoothly.

To resolve this, one might think that it’s simply a case of subclassing UIAlertView and amending its implementation. Unfortunately, UIAlertView does not support subclassing, so developers have to roll their own solution from scratch.

There are quite a few that I’ve discovered in recent days:

  • TBHintView which provides dropdown and popup alerts, with multiple page support
  • MKInfoPanel which replicates TweetBot’s dropdown panels
  • MBProgressHUD which shows a translucent view whilst work is performed in the background
  • DejalActivityView which contains a great variety of views
  • YRDropdownView which is inspired by many of the above

Of these, I rather like YRDropdownView, and notably Daniel Gindi’s fork of it that allows for Xcode’s Automatic Reference Counting (ARC).

Whilst it doesn’t currently support customisation of background colours this should be easy to add (since there are properties that define these). For the screenshot shown on the right, I merely tweaked the showDropdownInView method to alter the background.