I have a UIViewController with a UICollectionView. In viewDidLoad, I fetch the data from a network request. I create the cells after receiving the response. Once the UI updates, I use UIAccessibility.post(notification: .layoutChanged, argument: backButton) to update the focus to a back button. However, the focus doesn't shift to the back button; instead, it goes to the first cell of the collection view.
The back button is accessible, I test on a physical device and am able swipe through it.
Here's the interesting part: When I pause the debugger on the same line and execute po UIAccessibility.post(notification: .layoutChanged, argument: backButton), it works as expected when I continue. Has anyone encountered a similar issue? Any help would be greatly appreciated.
My goal is to shift the VoiceOver focus to a back button using the UIAccessibility.post method. However, the focus doesn't change as expected. Even when I've tried using DispatchQueue.main.asyncAfter with various delays, up to 10 seconds, there's no noticeable effect.
What could be causing this issue, and how can I ensure that the focus shifts to the back button after a delay?
Any insights or suggestions would be greatly appreciated.