我正在尝试获取选定的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
//......
//....
}
欲了解更多信息,请访问此链接。
好的,试着在你的didselect方法上获取单元格,如下所示:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UILabel *lblValue = (UILabel *)[cell viewWithTag:YourtagValueOfLabelinStoryboard];
NSLog(@"Your Label value:%@",lblValue.text);
}