我想在UITableview中加載大約6000-8000行。我從使用異步調用服務器獲取數據,當我得到的數據我打電話dequeueReusableCellWithIdentifier不起作用
[tableView reloadData]
這是刷新表視圖。但由於某種原因,我的應用程序被卡住並凍結。 當我調試時,我發現cellforrowatindexpath被稱爲6000次(在主線程上),並且 dequeueReusableCellWithIdentifier總是返回null。
- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath{
CDTableRowCell *cell = nil;
// Create and Resue Custom ViewCell
static NSString *CellIdentifier = @"CellIdentifier";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// got into render/theme objec
if(cell == nil){
cell = [[CDTableRowCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// MODIFYING CELL PROPERTIES HERE FROM AN ARRAY
// NO HTTP CALLS
}
此外,tableview開始重新使用單元格,一旦我開始滾動,但在此之前,我永遠不會總是創建一個新的。 任何線索爲什麼這種奇怪的行爲?
你有沒有機會告訴tableview每行的高度爲0?如果它認爲所有單元格都應該可見,則可以解釋此行爲。 –
@KevinBallard讓我檢查 –
@KevinBallard 我試過,但似乎並不工作 - (CGFloat的)的tableView:(UITableView的*)的tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 回報40; } –