iOS change accessibility focus.

John S picture John S · Sep 23, 2011 · Viewed 25.2k times · Source

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

Answer

Vlad picture Vlad · Apr 27, 2016

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]