0
votes
  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

Above Function is not Getting called when i select the cell inside UITableView which i have inserted inside the footerView of another UITableView

I have added the UITableView inside the below function and I able to see all the items which i have inserted

But I am not able to click on Cells.

I Have Also inserted Some UIButton to check if the click is working ,which working fine

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

thanks in advance.

- (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;
    }
}
1
Did you forget to set the delegate?Rick van der Linde
Delegate and data source both are set ..Pulkit Kumar Singh
Could you post some more code, this is just wild guessing :-)Rick van der Linde

1 Answers

3
votes

Since you have two UITableViews to control, the delegates of both the UITableViews have to be set correctly. Did you set these delegates?

By checking the UITableView in the delegate methods, you can control both 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
    }
}