【问题标题】:Objective-C linking two TableviewsObjective-C 链接两个 Tableview
【发布时间】:2017-04-05 06:33:02
【问题描述】:
我想要的是,当您单击表格中的任何单元格时,您会转到另一个表格视图。我还需要为您单击的每个不同的单元格提供不同的字符串。不过我不知道
1) 按下时如何将表格单元格链接到 ViewController 中的另一个表格视图
2)如何在视图控制器中为您单击的每个不同单元格更改详细的 Tableview(包括文本和音频文件)。
【问题讨论】:
标签:
objective-c
uitableview
tableview
【解决方案1】:
使用委托方法检测表格视图中的任何行点击
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
}
【解决方案2】:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSLog(@"index path cell row number =======%ld",(long)indexPath.row);//you can get the index number of that cell
NSLog(@"data of clicked cell====%@",[yourArray objectAtIndex:indexPath.row]);//here you can get the data of that cell
}