iOS change accessibility focus.

前端 未结 3 1295
挽巷
挽巷 2021-01-03 17:40

is there a way to set the accessibility focus programatically (App Store-safe)? Any help will be greatly appreciated.

3条回答
  •  温柔的废话
    2021-01-03 18:38

    To focus on element you can call.

    Swift:

    UIAccessibility.post(notification: .screenChanged, argument: self.myFirstView)
    

    ObjC:

    UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, self.myFirstView);
    

    Otherwise for iOS 8+ use the accessibilityElements to set element order and it will focus automatically on first element in the list

    self.accessibilityElements = @[myFirstView, mySecondButton, myThirdLabel]
    

提交回复
热议问题