2012-07-02 95 views
0

我用10行填充表格視圖。當我向上滾動表格時,前兩行或三行會被凍結一段時間。我只看到2或3秒的最後一行。 我意識到滾動表格會調用cellForRowAtIndexPath和willDisplayCell函數。我使用這些功能。看起來這些功能的調用減少了響應時間。 如何在滾動表格時禁用調用這些函數? 請注意,我不想禁用滾動。UITableView滾動

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
} 

cell.textLabel.text = [[self.items objectAtIndex:indexPath.row] valueForKey:@"name"]; 

if ([indexPath row] % 2) 
    cell.backgroundColor = [UIColor whiteColor]; 
else 
    cell.backgroundColor = [UIColor colorWithRed:0/255.0 green:46/255.0 blue:59/255.0 alpha:0.1]; 

return cell; 

回答

1

你不能做到這一點,那就是實現代碼如下的正常行爲,但是你應該增加這些功能的性能,例如,如果你從遠程源做負載圖像考慮使用懶加載技術

+0

我編輯的帖子包括代碼。 – Oktay

1

您無法停止調用這些方法。如果您發佈代碼,我們可以幫助您優化它們。

UITableViews緩慢的第一個原因是不重複使用您的單元格。你在重複使用你的單元格嗎?

+0

我編輯過的帖子包括代碼。 – Oktay