can I set accessibility identifier in interface builder? Xcode4.2

后端 未结 5 1638
孤街浪徒
孤街浪徒 2020-12-09 08:31

I can only set Accessibility Label in interface builder, but in UI Automation,I need Accessibility Identifier to get the UI elements. any way to do this?

5条回答
  •  温柔的废话
    2020-12-09 09:17

    The accessibilityIndentifier can be set in IB by using the Identity Inspector tab's 'User Defined Runtime Attributes':

    Key Path: accessibilityIdentifier

    Type: String

    Value: Chosen accessibilityIdentifier text

    E.g. setting a scroll view to have the accessibility ID 'ScrollView':

    Note: This can only be used on items that have the accessibilityIdentifier property meaning they inherit from UIView. Also, typos in 'Key Path' will probably cause an exception when the item is loaded, I don't believe a compile warning/error would be given.

提交回复
热议问题