通过Cell的UIButton获取UITableViewCell的行数

来源:互联网 发布:网络信息安全自查报告 编辑:程序博客网 时间:2024/06/07 12:03

在UIButton的点击事件中做处理,以下是两种方法:

方法1:

UITableViewCell * cell = [(UITableViewCell*)[sender superview] superview];    NSIndexPath * indexPath = [self.table indexPathForCell:cell];    DLog(@"cell's row %d",indexPath.row);

方法2:

UIButton * btn = (UIButton*)sender;    CGRect buttonRect = btn.frame;    for (UITableViewCell *cell in [self.table visibleCells]) {        if (CGRectIntersectsRect(buttonRect, cell.frame)) {            //TODO        }    }
0 0