2009-07-24 76 views

回答

10

null0row属性是int类型 - 也许你错误地将它用作对象或指针。

你提到你想要选择的实际“行”。如果你的意思是你想要的细胞选择的是,这里的如何:

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 

需要注意的是,如果你以某种方式编程方式选择一排,这不是当前可见,这将返回nil

+0

我用错了数组访问方法:-S – mjmdavis 2009-07-24 15:39:44

0

它将PATH返回到所选行,而不是行(或单元格)本身。

indexPath(0,0)是第一部分的第一个单元格。根据你正在运行的测试,这可能是正确的结果。

1

indexPath.section告诉你它要求的部分。

indexPath.row告诉你它想要的那一段中的哪一行。

无论从0开始。

你想要做这样的事情:

if (indexPath.section == 0) {  // 1st section 
    if (indexPath.row == 0) return cell1; 
    if (indexPath.row == 1) return cell2; 
    if (indexPath.row == 2) return cell3; 
} else if (indexPath.section == 1) {  // 2nd section 
    if (indexPath.row == 0) return cell4; 
    if (indexPath.row == 1) return cell5; 
    if (indexPath.row == 2) return cell6; 
} 
return nil; 
相关问题