iphone - UITableView DidSelectRowAtIndexPath?

标签 iphone objective-c ios xcode ipad

我有一个包含一些项目(全是文本)的表格 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/

相关文章:

iphone - iOS - 状态栏随机变为纯黑色

ios - 如何证明标签文本的合理性?

ios - 检查 iOS9 设备是否支持并启用 3D touch

iphone - 平滑滚动/惯性滚动/动量滚动

iphone - 如何从它创建的对象中引用 Controller ?

objective-c - 带有音频文件的 iPhone 应用程序太大了。如何减小尺寸?

ios - 在 Storyboard 中更改 super View 后保持自动布局约束

ios - TiWebView : Submitting data to a self signed https URL from a local html file on iOS cause error

ios - UIActionsheet 委托(delegate) clickedButtonAtIndex 永远不会被调用

iphone - 使用 XCode for iPhone 实现多线程