UITableView Setting some cells as “unselectable”

后端 未结 16 1467

How can I set the UITableView\'s cell property to be unselectable? I don\'t want to see that blue selection box when the user taps on the cell.

16条回答
  •  遥遥无期
    2020-12-12 18:24

    Apple says that the first thing you should do in didSelectRowAtIndexPath is to deselect the row

    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:NO];
    

    Then you can change the AccessoryType to be a checkmark, or none, etc. So when you enter didSelectRowAtIndexPath you could deselect the row, and if its not meant to be selected, simply don't check that row.

    Table View Programming Guide

提交回复
热议问题