2

The "Accessibility Programming Guide For iOS" states:

Another way is to implement the isAccessibilityElement method of the UIAccessibility protocol in the implementation of your custom subclass. The following code snippet shows how to do this:

But when I am doing so, as in the following code:

class UITextLayerLabel : UIView, UIAccessibility {

XCode returns me this error:

 [...] Use of undeclared type 'UIAccessibility'

What I am missing? A specific import? Is the protocol still available with iOS 10/XCode8?

yves Baumes
  • 8,836
  • 7
  • 45
  • 74
  • If your class inherits UIView, you have automatically the UIAccessibility protocol methods that are accessible because UIView conforms to this informal protocol. Don't specify the protocol in your example and it should work like a charm. – XLE_22 Jul 20 '17 at 08:11

1 Answers1

3

As pointed out here, UIAccessibility is an informal protocol. For the difference between an informal protocol and a formal one, see here.

Basically, there is no type called UIAccessibility. Actually, UIView is already conforming to UIAccessibility. To make your custom view accessible, just override the properties and methods starting with accessibility.

So when do you need to implement UIAccessibility? As stated here,

You can use UIAccessibilityElement to provide information about an icon or text image is not automatically accessible because it does not inherit from UIView (or UIControl ). A view that contains such nonview items creates an instance of UIAccessibilityElement to represent each item that needs to be accessible.

Sweeper
  • 213,210
  • 22
  • 193
  • 313