uicllectionViewUITableView实用工具

设置TableView的某个cell上Button的选中状态(思

2016-02-19  本文已影响4685人  HarrisHan
选中某个cell.gif
- (void)selectedBtnClick:(UIButton *)button
{
    // 通过button计算出其所在的cell
    UITableViewCell * cell = (UITableViewCell *)[[button superview] superview];
    NSIndexPath * path = [self.hsTabbleView indexPathForCell:cell];

    // 记录下当前的IndexPath.row
    self.indexPathRow = path.row;
    
    // 刷新数据源方法
    [self.hsTabbleView reloadData];
    
}
- (void)selectedBtnClick:(UIButton *)button
{
    // 通过button计算出其所在的Cell
    UITableViewCell * cell = (UITableViewCell *)[[button superview] superview];
    NSIndexPath * path = [self.hsTabbleView indexPathForCell:cell];

    // 记录下当前的IndexPath.row
    self.indexPathRow = path.row;
    
    NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:path.section];
    // 刷新数据源方法
    [self.hsTabbleView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
    
}
if (self.indexPathRow == indexPath.row) {
            // 如果是当前cell
            cell.supportBtn.selected = YES;
            
        }else{
            
            cell.supportBtn.selected = NO;
            
        }
上一篇下一篇

猜你喜欢

热点阅读