1.cell中设置按钮两种状态
2.controller中设置
self.lastSelectTag 全局变量,记录最后一次点击按钮tag值
3.cellForRow中:
cell.selectBtn.tag =100 + indexPath.row;
[cell.selectBtn addTarget:selfaction:@selector(selectAction:)forControlEvents:(UIControlEventTouchUpInside)];
//关键
cell.selectBtn.selected =self.lastSelectTag == cell.selectBtn.tag;
4.点击方法
- (void)selectAction:(UIButton *)sender{
if (self.lastSelectTag) {
UIButton *btn = [self.viewviewWithTag:self.lastSelectTag];
btn.selected =NO;
}
sender.selected =YES;
self.lastSelectTag = sender.tag;
}