一:pop返回table时,cell自动取消选中状态
需求:
一个ViewController,上边有tableView,选择不同的cell会push进入下一层,返回进入ViewController时,上一次选择的cell还是点击选中状态,UITableViewController就不会这样。
原因:
UITableViewController有一个clearsSelectionOnViewWillAppear的property,而当把UITableViewController修改成UIViewController后,这个属性就不存在了.
解决:
在viewWillAppear方法中加入:
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
二:点击过后,取消点击(最简单,常用的)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectedRowAtIndexPath:indexPath animated:YES];
}