Search code examples
tableviewcell

TableView Cell - mark specific row as selected when page loads


Normally when a TableView loads no cell is selected until you touch the screen. How do I make a particular row be selected? This row is derived from a database.


Solution

  • - (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition
    

    is the method you need.

    You can read more about it on Apple's site.

    https://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/selectRowAtIndexPath:animated:scrollPosition: