Search code examples
cocoa-touchiosuitableviewnsindexpath

Can I programmatically modify which UITableViewCell is selected?


Is there a way to move the highlighted tableviewcell programatically. If I wanted to highlight cell number 3 and then highlight cell number 4 instead, based on something the user did in the detail view of my split view controller, can I do this?

Is there a way I can get the indexpath for the row two below one that I have?

Thanks!


Solution

  • You can do this via the UITableView selectRowAtIndexPath:animated:scrollPosition: method.

    In terms of getting the "next" row from the indexPath, you can simply use the indexPath.row property (as supplied from your UITableViewDelegate's tableView:didDeselectRowAtIndexPath: method) as the basis for the selected row.