Tyler Pfaff Tyler Pfaff - 1 year ago 80
iOS Question

What's the difference between setAccessibilityLabel and accessibilityIdentifier in ios?

I've been going through our code base and setting the accessibilityIdentifier property on all of our buttons and text fields so that I can access them using UIAutomation. While doing this, I came across some code that was already in place.

[_goodButton setAccessibilityLabel:@"off"];

I can't find any documentation on what the differences are between these two methods. It looks like they do the same thing. Does anyone know? I find it peculiar that this label is set to "off" as well.

Answer Source

Instead of using accessibilityLabel (see below) you should use accessibilityIdentifier.

This github issue explains the difference:

Given that accessibilityLabel is an outwardly-facing string that is actually used by accessibility screen readers (and should be localized to the device user's language), Apple now provides an alternate property (iOS 5+) that is specifically intended for UI Automation purposes

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download