在另一个表的FooterView内部添加UITableView(在添加的UITableView上未调用didSelect


  • (void(tableView:(UITableView*(tableView didSelectRowAtIndexPath:(NSIndexPath*(indexPath

当我选择UITableView中的单元格时,上面的函数没有被调用,我已将该单元格插入另一个UITableView的页脚视图

我在下面的功能中添加了UITableView,我可以看到我插入的所有项目

但我无法点击Cells。

我还插入了一些UIButton来检查点击是否有效,这很好

  • (UIView*(tableView:(UITableView*(tableView viewForFooterInSection:(NSInteger(section

提前谢谢。

- (UIView *)tableView:(UITableView * )tableView viewForFooterInSection:(NSInteger)section {
    if(tableView==_ordersListTable)
    {
//creating view to pass to footerview
    UIView *footerView;
        footerView.userInteractionEnabled=true;
    if(footerView == nil) {
        //allocate the view if it doesn't exist yet
        footerView  = [[UIView alloc] init];
}
       //initializing table
                _paymentInfoTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 40, 320, 80)];

      _paymentInfoTable.backgroundColor = [UIColor whiteColor];
        _paymentInfoTable.delegate = self;
        _paymentInfoTable.dataSource = self;
        //_paymentInfoTable.separatorStyle = UITableViewCellSeparatorStyleNone;
        _paymentInfoTable.separatorInset = UIEdgeInsetsMake(0, 110, 0, 180);
        [footerView addSubview:_paymentInfoTable];
    }
    //return the view for the footer
        return footerView;
} else
    {
        return 0;
    }
}

由于要控制两个UITableView,因此必须正确设置这两个UItableView的委托。您是否设置了这些代表?

通过检查委托方法中的UITableView,您可以控制两个UITableViews:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.tableView1) {
        // Do your thing with the first UITableView
    }
    else {
        // Do your thing with the other UITableView
    }
}

最新更新