There is simply no API for supplying custom element actions to VoiceOver. No UIAccessibility*
protocol provides anything for this to be possible. I guess you should file a radar if you need to add custom actions and hope Apple will implement it in some future version of iOS (or that it will appear in iOS 7 in a month).
UPDATE: As of iOS 8, you can set/implement the accessibilityCustomActions
property to return an array of your UIAccessibilityCustomAction
objects (note that VoiceOver will still add the "Activate Item" default action in its UI in addition to what you provide.):
self.accessibilityCustomActions = [
UIAccessibilityCustomAction(name: NSLocalizedString("Close", comment: ""), target: self, selector: "didPressClose")
]
...
@objc
func didPressClose() -> Bool {
...
}
As usual with Swift and selectors, don't forget to add the @objc
attribute to the target method of the custom action in Swift if you don't subclass NSObject
/the method is private, otherwise on attempting to activate the action with VoiceOver, it will not do anything and play the "end of bounds reached" sound (at least on iOS 8.2 and 8.3 where I tested with target object that did subclass NSObject
).
Regarding your second question - feels like a bug which you can again file a radar for :-)