Today’s ex-bug is a doozy.  I have code which has been running on iOS since iOS3 and it just stopped working recently in iOS6.

UIAlertView is an API call which presents a popup ‘dialog’ at the bottom of the screen with one or more buttons used in situations like confirmation of a delete from a UITableView.

One of our apps was built on the ‘utility’ model in which there’s a main view and one or more modal views which appear like turning a card over (i.e. a flip along the vertical axis from right-to-left as you go deeper and left-to-right as you unwind).

In the main view, there was a delegate method named ‘canBecomeFirstResponder’ which is used to provide start/pause/resume control of the audio recording via the headphone play/pause.

However, when showing an UIAlertView in one of the ‘modal’ views, the canBecomeFirstResponder of the main view was being called and returned YES even when the main view wasn’t visible.

The fix, for us, was to keep track of when the ‘modal’ views were on-screen and return NO to the call to canBecomeFirstResponder and it works like a champ!

Chalk up one for the good guys and we’re off to the App Store to put the update in the queue for review!