ios - 如何使用 Objective C 获取 Tableview 选择的单元格 UILabels 值?

标签 ios objective-c iphone uitableview

我正在尝试获取选定的 cell 行标签值。我在 tableview 单元格上维护了多个 label 值。每当我选择单元格时,我都需要获取值。我没有太多代码,我正在使用以下方法

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

最佳答案

您只需将此代码添加到您的项目中..

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Simpletablecell *cell = (Simpletablecell *)[tableView cellForRowAtIndexPath:indexpath]; // SimpletableCell is your cell you can add your cell here like UITableViewCell..
self.lbl1.text = cell.lbl3.text;// cell.lbl3 is a label of cell.
self.lbl2.text = cell.lbl4.text;// here only two labels values get you can get other labels also 
//......
//....
}

有关更多信息,请访问此 link .

关于ios - 如何使用 Objective C 获取 Tableview 选择的单元格 UILabels 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34327127/

相关文章:

iphone - 如何检测 iPhone OS 设备是否具有接近传感器?

ios - 补充意见未被删除

objective-c - 在 Controller 实例变量中存储现有对象时是否需要 'retain'?

ios - CloudKit:将容器环境从开发切换到生产

iphone - 如何在 UITableView 单元格中设置背景图像?

iphone - 如何调整 UIImageView 的大小以适应底层图像而不移动它?

iOS 10 错误多次记录导致应用程序挂起

ios - Backendless - 如何从 'Data' 获取对象

ios - 分组 UITableview 中减少单元格

ios - Xcode7 核心绘图错误 : CPTPlot, NSString