如何在NSLog中显示从我的tableview中选择的单元格?
答案 0 :(得分:4)
实施 didSelectRowAtIndexPath UITableview委托并记录 indexPath.row 。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"selected tableview row is %d",indexPath.row);
}
答案 1 :(得分:3)
如果要显示单元格中显示的内容,例如在textLabel上,在didSelectRowAtIndexPath中使用它:
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"selected cell textLabel = %@",cell.textLabel.text);