开发者

How to catch select event of table cell

开发者 https://www.devze.com 2023-04-13 05:50 出处:网络
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 whi

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.

How to catch select event of table cell

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


You need to implement the delegate method

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


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

See also docs - UITableViewDataSource Protocol


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

{

//where indexPath.row is the selected cell

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

}

0

精彩评论

暂无评论...
验证码 换一张
取 消