How to highlight a row in a UITableView

前端 未结 6 1130
名媛妹妹
名媛妹妹 2020-12-31 10:00

The code below seems to have no effect. I want it to be highlighed in the same way it highlights when you tap on a row

- (UITableViewCell *)tableView:(UITab         


        
6条回答
  •  萌比男神i
    2020-12-31 10:59

    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection: 0];
    
    [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    

    usually works

    If you are using interface builder to build your interface, one thing to check is that you specified the view of the table view controller. If you don't actually specify the view, this selection message may go nowhere.

    (you specify the view by selecting the table view controller in the interface builder inspector window and dragging the outlet for "view" to the table view you want to do the selection in).

提交回复
热议问题