我有一个包含一些项目(全是文本)的表格 View 。当用户单击该行时,我希望将该单元格中的文本添加到数组中。
如何从单元格中抓取文本?
我已经有:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
我可以使用简单的一行来从用户点击的单元格中抓取文本吗?
最佳答案
使用UITableView
's cellForRowAtIndexPath:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = cell.textLabel.text;
}
关于iphone - UITableView DidSelectRowAtIndexPath?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8404922/