美文网首页
[self.tableView indexPathForCell

[self.tableView indexPathForCell

作者: 失忆的程序员 | 来源:发表于2020-06-19 14:33 被阅读0次

我是要对cell 多个按钮做事情,然后遇到这个问题,

indexPathForCell

反馈 nil

解决方法

按钮对外事件

if ([button isKindOfClass:[UIButton class]]) {

        UIView *view = button;

        while (![view isKindOfClass:[UITableViewCell class]]) {

            view = [view superview];

        }

}

- (void)onActionOrderOk:(UIButton *)button

{ // 同意

    if ([button isKindOfClass:[UIButton class]]) {

        UIView *view = button;

        while (![view isKindOfClass:[UITableViewCell class]]) {

            view = [view superview];

        }

        //UIView *contentView = [button superview];

        //MyOrderVCCell_2 *cell = (MyOrderVCCell_2 *)[contentView superview];

        MyOrderVCCell_2 *cell = (MyOrderVCCell_2 *)view;

        NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];

        UIButton *okbtn = [cell viewWithTag:indexPath.row + 40012];

        okbtn.hidden = YES;

        UIButton *nobtn = [cell viewWithTag:indexPath.row + 50012];

        nobtn.hidden = YES;

        UIButton *okReceiptbtn = [cell viewWithTag:indexPath.row + 70012];

        okReceiptbtn.hidden = NO;

        XPFLog(@"%@----%@", indexPath, self.dataMutAry[indexPath.row]);

    }

}

相关文章

网友评论

      本文标题:[self.tableView indexPathForCell

      本文链接:https://www.haomeiwen.com/subject/gbbvxktx.html