Ranganatha G V
Ranganatha G V

Reputation: 415

how to find which UITableView row has been clicked ? I have multiple UITableviews on UIScrollView.

I have implemented around 10 tables on UIScrollView. I want to know which row of which UITable has been clicked.

thanks in advance.

Upvotes: 1

Views: 96

Answers (1)

Vidya Murthy
Vidya Murthy

Reputation: 530

You can add tags to each of the table and then check it in didSelectRowAtIndexPath

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(tableView.tag == 1){
    //do something
    }
    else if(tableView.tag == 2){
    //do something else
    }
    // and so on
}

Or else, you could check which instance of tableview is calling the delegate method:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(tableView == self.tableView1){
    //do something
    }
    else if(tableView == self.tableView2){
    //do something else
    }
    // and so on
}

Upvotes: 2

Related Questions