VoiceOver support for custom text editors

When I originally released Pear Note for iPad a little over a year ago, it did not include VoiceOver support. I had hoped to include it in 1.0, but ended up pushing it off. Soon after release, thanks to some emails from users, I started looking into providing VoiceOver support.

iOS makes it easy to add VoiceOver support for most controls. A button simply needs a label that the system can read. Some different kinds of views are much more complicated, and the most complicated of them all is the text editor. If you use the built-in UITextView class, it handles all of this complication for you. Users can scrub around the text, advance by different granularities using the rotor, and edit the text without needing to see anything.

Pear Note, however, has a custom text editor to provide many capabilities beyond UITextView. It draws text to the screen using Core Text and captures input by complying with the UITextInput protocol. I wanted to have my custom text editor emulate the VoiceOver behavior of UITextView. I searched for protocols to conform to and hacks I could implement to accomplish this, but I came up with nothing. Finally I filed a support incident with Apple, and was told that indeed there was no way for a custom text editor to support VoiceOver. So, I filed a rdar (which was soon closed as a dup) and accepted that I could not do this.

When iOS 6 was in beta, I scoured the API changes to see if they had added support for this. Alas, I found nothing. So, I gave up for another year, hoping iOS 7 might hold a possibility of this. Then, a few weeks after iOS 6 shipped, I was going through my bugs on bugreport.apple.com and noticed something odd. My bug was still closed as a dup, but the bug that it was a dup of was also now closed. I again searched the documentation to find anything new in this area, but found nothing.

So, I submitted another support incident to Apple asking what was going on. It turns out that they had indeed added support for VoiceOver in custom text editors in iOS 6, but they had done so without any changes to the published API. They simply made VoiceOver work with the existing UITextInput protocol that editors must conform to. So, they had added this functionality under the hood and not updated any documentation to tell us about it.

I quickly tested Pear Note and found that while it was completely broken since I'd never tested it, VoiceOver was indeed trying to work. I spent a few days fixing bugs and improving my string tokenizer, and then I had working VoiceOver support in Pear Note.

So, if you're looking to provide VoiceOver support for a custom text editor, it is now possible in iOS 6 despite not being documented anywhere. Just conform to UITextInput and make sure your tokenizer is fully functioning.