How do I set the UIAccessibility
focus on the content of the selected tab of a UITabBarController
? It's keeps focussing on the selected UITabBarItem
.
I've tried to set the focus in the UITabBarControllerDelegate
:
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
if let destination = (viewController as? UINavigationController)?.viewControllers.first {
UIAccessibility.post(notification: .screenChanged, argument: destination)
} else {
UIAccessibility.post(notification: .screenChanged, argument: viewController)
}
}
I've also tried to set the focus in the selected UIViewController
:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIAccessibility.post(notification: .screenChanged, argument: accessibilityElements?.first)
}
The accessibility focus does not change unfortunately. I'm not sure if this is an iOS 13 issue or a general tabbar issue, as even Apples own AppStore app does not change accessibility focus when selecting a tab.