开发者

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.

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜