UITableView reloadRows resets focus

I have a UITableViewController shared between my iOS and tvOS apps. In order to refresh some of the cells, I call reloadRows. It works fine as far as updating the cell's data but, on tvOS, it moves the focus back to the top of the table. I've noticed that preferredFocusEnvironments does not get called (unlike what happens when I do reloadData).

This is pretty much the same issue mentioned in the following post (years ago): https://developer.apple.com/forums/thread/67219

Any suggestions?

Answered by bbousquet in 707696022

Ok, I may have found a solution by using UITableViewDelegate's indexPathForPreferredFocusView instead of relying on preferredFocusEnvironments.

Maybe you could save the focus before calling and restore just after ?

Accepted Answer

Ok, I may have found a solution by using UITableViewDelegate's indexPathForPreferredFocusView instead of relying on preferredFocusEnvironments.

UITableView reloadRows resets focus
 
 
Q