UITableView DidSelectRowAtIndexPath? [英] UITableView DidSelectRowAtIndexPath?

查看:109
本文介绍了UITableView DidSelectRowAtIndexPath?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有几个项目的表视图(所有文本)。当用户单击该行时,我希望将该单元格中的文本添加到数组中。

I have a table view with a few items (all text). When the user clicks the row I want that text in that cell to be added to an array.

如何从单元格中取出文本?

How Do I grab the text out of the cell?

我已经拥有:

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

}

是否有一个简单的行可以用来从用户点击的单元格中取出文本?

Is there a simple line I can use to grab the text out the cell that the user clicks?

推荐答案

使用 UITableView cellForRowAtIndexPath:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSString *cellText = cell.textLabel.text;
}

这篇关于UITableView DidSelectRowAtIndexPath?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆