What's the preferred way to set accessibility label on UIActionSheets

cocoa-touch, iphone, objective-c

Solution

From the UIKit User Interface Catalog:

Action sheets are accessible by default.

Accessibility for action sheets primarily concerns button titles. If VoiceOver is activated, it speaks the word “alert” when an action sheet is shown, then speaks its title if set (although iOS human interface guidelines recommend against titling action sheets). As the user taps a button in the action sheet, VoiceOver speaks its title and the word “button.”

From your question it's not clear if you want to change the accessibility label to something other than the button title + button, but it appears that that's not possible in a straight-forward way.

Problem

Looking at adding KIF to our app for integration testing. I'd like to be able to select a button from a UIActionSheet but it doesn't seem like there's an efficient way to set the accessibility labels on each button in the action sheet. I'm looking at using the accessibleElementCount, iterating through the buttons that way. Is that the preferred way to do this or is there a more standard way of setting up accessibility for UIActionSheets?

Original source