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

前端 未结 4 447
感情败类
感情败类 2021-01-31 14:32

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

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-31 15:13

    You check this one

    Accessibility Label and Identifier Attributes The label attribute and identifier attribute figure prominently in your script’s ability to access UI elements. It is important to understand how they are used.

    Setting a meaningful value for the label attribute is optional, but recommended. You can set and view the label string in the Label text field in the Accessibility section of the Identity inspector in Interface Builder. This label is expected to be descriptive, but short, partly because assistive technologies such as Apple’s VoiceOver use it as the name of the associated UI element. In UI Automation, this label is returned by the label method. It is also returned by the name method as a default if the identifier attribute is not set. For details, see UIAccessibilityElement Class Reference.

    The identifier attribute allows you to use more descriptive names for elements. It is optional, but it must be set for the script to perform either of these two operations:

    Accessing a container view by name while also being able to access its children. Accessing a UILabel view by name to obtain its displayed text (via its value attribute). In UI Automation, the name method returns the value of this identifier attribute, if one is set. If it is not set, the name method returns the value of the label attribute.

    Currently, you can set a value for the identifier attribute only programmatically, via the accessibilityIdentifier property. For details, see UIAccessibilityIdentification Protocol Reference.

提交回复
热议问题