I have a button and when I tap the button, there will be an alert.
When I have voiceover on and tap the button, then tap the alert OK button to dismiss the alert, the focus will go back to the top of the page/back button, rather than the button that triggers the alert.
I'm using this chunk of code to move the focus back to the button:
let dispatchTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(0 * Double(NSEC_PER_SEC)))
dispatch_after(dispatchTime, dispatch_get_main_queue(), {
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, button)
})
The problem is after you dismiss the alert, the focus will go back to the top and read the label first, then go back to the button. The focus is not going to the button directly, which looks pretty lame.
I checked some Apple app, and I find that after they dismiss the alert, the focus will go back to the previous element before the alert pops up. Any idea how to achieve this? Thanks!