所以我一直在嘗試從UITableView加載單元格,並將它們放入NSMutableArray中,以便稍後迭代。我有一個名爲populateArrayWithCells的方法,它可以正常工作,直到我放入6個以上的單元格。出於某種原因,返回的對象是零。我的代碼是下面,StocksAndAccounts是UITableView的,我已經在子類部分中的UITableViewCells 1.循環遍歷UITableView的UITableViewCells
- (void) populateArrayWithCells
{
for (int i = 0; i < [StocksAndAccounts numberOfRowsInSection:1]; i++) {
if ([StocksAndAccounts cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:1]] == nil) {
NSLog(@"object at index %i is nil", i);
}
[stocksCells addObject:[StocksAndAccounts cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:1]]];
}
}
該功能,通過一個IBAction爲調用時,則返回該細胞successfuly直到索引是6,在這種情況下,它是零和崩潰,因爲它試圖添加一個零的對象。任何有關這個問題的幫助將不勝感激。
你爲什麼要這麼做。 – bryanmac 2012-01-14 02:20:20
Uitableview具有數據的委託回調模式,並且存在單元重用隊列 – bryanmac 2012-01-14 02:21:05
同意 - 爲什麼要這樣做?這聞起來像一個設計缺陷。 – 2012-01-14 02:22:36