2

是否可以在 tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 方法中找到我单击的行部分。

TIA

4

4 回答 4

10

indexPath 参数具有可访问的部分属性,如下所示

[indexPath section]; 

或者

indexPath.section
于 2012-08-06T10:59:26.473 回答
2
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

 if(indexPath.section==0)
 {

    // 1st Section of the tableView.

   if(indexPath.row==0)
   {

      // 1st cell of the 1st section.

   }
 }
}
于 2012-08-06T11:06:33.977 回答
2
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

   int section = [indexPath section];

}
于 2012-08-06T11:08:15.973 回答
2
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:
(NSIndexPath*)indexPath{
    int section = [indexPath section];
    NSLog(@"section %d",section);
}
于 2012-08-06T11:27:47.710 回答