-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
// 开始的时候 tableView 的 cell 的selected 为0 当选中一个的时候 之前被选中的 cell 的selected 设置为0, 新选中的 cell 的selected设置为1; [ super setSelected:selected animated:animated];
// - 例如下边的例子
1.设置 cell 的 textLabel 的 textColor(选中时候是红色的,非选中时候是灰色的)
self.textLabel.textColor = selected?[UIColor redColor] : [UIColor grayColor];
2. 设置 cell 中的某个控件的隐藏和显示(在选中 cell 时候显示,在非选中的状态 隐藏)
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
self.selectedIndicator.hidden = !selected;
}
// - 设置 cell 的 accessoryView
cell.accessoryView = [UIView alloc]init];
// - 返回 tableview 当前选中的 index
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];