2009-07-24 73 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; 
相關問題