[self.tableView indexPathForCell

2020-06-19  本文已影响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]);

    }

}

上一篇下一篇

猜你喜欢

热点阅读