2012-09-23 30 views

回答

3

實施didSelectRowAtIndexPath UITableview委託並記錄indexPath.row

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

    NSLog(@"selected tableview row is %d",indexPath.row); 
} 
+0

謝謝,它的工作原理! :) –

+0

截至Xcode 5+ NSLog(@「selected tableview row is%ld」,(long)indexPath.row); 應該做的伎倆。 –

2

如果要顯示單元格中顯示的內容,例如,在它的textLabel上,在didSelectRowAtIndexPath中使用它:

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
NSLog(@"selected cell textLabel = %@",cell.textLabel.text);