显示在NSLog中选择的tableview行

时间:2012-09-23 09:11:23

标签: iphone sdk tableview nslog

如何在NSLog中显示从我的tableview中选择的单元格?

2 个答案:

答案 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);
相关问题