DarkLeafyGreen
DarkLeafyGreen

Reputation: 70466

How to catch select event of table cell

I have an UIViewController where I have placed some single table cells. Most of them are just a nice way to display data which does not allow any interaction. But now I added a cell which needs to be clicked to open another view.

enter image description here

How can I see that the cell was clicked? How do I implement that?

Upvotes: 1

Views: 4807

Answers (3)

Thamizhvel
Thamizhvel

Reputation: 11

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath

{

//where indexPath.row is the selected cell

[self performSegueWithIdentifier:@"showMobileDetail" sender:indexPath];

}

Upvotes: 0

makboney
makboney

Reputation: 1824

You need to implement the delegate method

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    //where indexPath.row is the selected cell
}

Upvotes: 8

beryllium
beryllium

Reputation: 29767

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

See also docs - UITableViewDataSource Protocol

Upvotes: 0

Related Questions