1

在方法中

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // do stuff here
}

我有一个分组表视图。如果我希望第 1 节的第 1 行吐出一个NSLog,我会怎么做?另外,如果我想让第 3 节的第 2 行记录日志,会有什么不同吗?到目前为止,我只使用这种方法在笔尖之间进行转换。

4

1 回答 1

6

简单粗暴:

if(indexPath.row == 1 && indexPath.section == 1) {
  NSLog(@"Awesomeness");
} else if(indexPath.row == 2 && indexPath.section == 3) {
  NSLog(@"Something more awesome");
}
于 2011-05-22T15:15:18.647 回答