2
如何在NSLog中顯示從我的tableview中選擇的單元格?顯示在NSLog中選擇的tableview行
如何在NSLog中顯示從我的tableview中選擇的單元格?顯示在NSLog中選擇的tableview行
實施didSelectRowAtIndexPath UITableview委託並記錄indexPath.row。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"selected tableview row is %d",indexPath.row);
}
如果要顯示單元格中顯示的內容,例如,在它的textLabel上,在didSelectRowAtIndexPath中使用它:
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"selected cell textLabel = %@",cell.textLabel.text);
謝謝,它的工作原理! :) –
截至Xcode 5+ NSLog(@「selected tableview row is%ld」,(long)indexPath.row); 應該做的伎倆。 –