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

后端 未结 5 1634
孤街浪徒
孤街浪徒 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:01

    According to this page

    http://developer.apple.com/library/ios/#documentation/AnalysisTools/Conceptual/WhatsNewInstruments/NewFeatures42/NewFeatures42.html

    UIAutomation will use the accessibilityLabel if the accessibilityIdentifier is not set, so you can use that instead for now. This probably isn't best practice though because the accessibilityLabel is visible (or rather audible) to the user if they are using VoiceOver, but it's okay as long as you give the labels names that are meaningful to humans.

    Hopefully Apple will add a way to set the accessibilityIdentifier in IB in future, but for now you'll have to set it in code, or use something else such as the view tag to target views for automation.

提交回复
热议问题