I'm searching for a callback function of UITableView
when the row is focused for when I navigate with apple remote and press up or down to select the row (not when I press enter).
On iOS we have didSelectRowAtIndexPath
thats called when user selects the row but I can't find the function that is called when user navigates in the UITableView
.
You must implement this delegate method:
- (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
{
//this gives you the indexpath of the focused cell
NSIndexPath *nextIndexPath = [context nextFocusedIndexPath];
}
then you can do whatever you want with it in that function
Testing this in mid-2019, nextFocusedIndexPath does not seem to be available from the context object anymore. But it wasn't too hard to work around:
override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
let cell = context.nextFocusedView as! UITableViewCell
let indexPath = table.indexPath(for: cell)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With