Hello. I'd like to improve my keyboard focus experience on iPad in one of the usage scenarios of my app - browsing through two UICollectionViews in a master-detail pattern.
I am able to navigate the master collection view with the arrow keys, and focus is indicated correctly; however, after selecting an item with the keyboard, which pushes the detail collection view on the same navigation stack, the focus indicator disappears and the following message appears in the console:
[UIFocus] Starting to defer focus updates.
followed by a symbolicated stack trace. At this point, the user has to tap one of the arrow keys so that the focus indicator reappears. In this case, if the user then exits the detail collection view, which reveals the master collection view, the item that was focused and selected on the master collection view will be indicated correctly. The console shows the following message:
[UIFocus] Disabling focus deferral.
followed once again by a symbolicated stack trace.
Interestingly, the focus indicator also disappears after a period of time if the user leaves the app open and does not interact with it. In that case, the same message about starting to defer focus updates will appear, and the subsequent stack trace will contain an __NSFireTimer frame.
My question would be - what are the criteria for focus deferral and how can I control its behavior?
Thank you. Please let me know if I can add any relevant details to this thread.
Focus deferral is a state in which the focus system keeps track of an item to focus on but it suppresses the update to that item. This means that nothing is focused. This happens whenever the system thinks that the user is not using focus or that the context the user was focusing on is no longer available.
In your case the stack trace indicates that the view or a superview of the focused item is disappearing from screen so focus starts deferring focus again because the context the user was focusing on got removed.
This is expected if you push on to the same navigation stack the user was interacting with as the focused cell goes away, however focus should then try and find a new view in that same stack. It sounds like for some reason the focus system is unable to do so, maybe because at the time it tries there are no focusable views? Are you dynamically loading content?
You might get more logs if you launch your app with the UIFocusLoggingEnabled=1 launch argument, specified in Xcode.