我已經嘗試了所有的方法,如運行在主線程等.... 但他們都沒有工作.. 我的表有超過500行,其中包含圖像音頻以及文本.. 每次重新載入表時至少需要5到10秒的時間,並且ui是凍結的。 請幫我在這...表重新加載需要太多的時間來更新單元
回答
u可以使用NSOperational隊列:
NSOperationQueue *que = [[NSOperationQueue alloc]init];
[que addOperationWithBlock:^{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
//u can assign all the table view values and content here
// it will not pause the data u can scroll immediately
}];
}];
溶液2:
呼叫烏爾數據:
dispatch_async(dispatch_get_main_queue(), ^{
//call ur data methods or web services methods in side this block
});
分配表中的視圖中的數據:
NSOperationQueue *que = [[NSOperationQueue alloc]init];
[que addOperationWithBlock:^{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
//u can assign all the table view values and content here
// it will not pause the data u can scroll immediately
}];
}];
感謝您的回覆....更多的時間在heightForRowAtIndexPath同時計算單個行的高度...當我重新加載表時,它需要更多的時間500行高度和不同的高度...你的方法將正常工作。 。但問題是它需要3秒的時間來更新表後高度計算 –
RU從服務器獲取數據填充表或本地內存 –
從本地數據庫/內存獲取數據 –
你需要使用GCD此:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),
// do backgroud work
^{
dispatch_async(dispatch_get_main_queue(), ^{
// do UI work like
// label.text = ""
// or many others
});
});
除了@KKRocks答案,在大多數情況下,沒有必要填充表的所有500行,你可以只填充50個,並在滾動到底部時動態添加單元格。
認爲你正在使用的電池創作
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
數據源的方法以及數據的設置。我的建議是僅將數據源方法用於單元格創建。然後使用
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
代表設置數據的方法。使用此示例代碼
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyWishListTableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"Order_Cell_Indntifire"
forIndexPath:indexPath];
return cell;
}
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell isKindOfClass:[MyWishListTableViewCell class]])
{
MyWishListModel* data = [_myWishListArray objectAtIndex:indexPath.row];
MyWishListTableViewCell *cell1 = (MyWishListTableViewCell*)cell;
[cell1 setUpData:data];
}
}
- 1. JRebel花費太多時間來更新
- 2. AutoCompleteTextView需要這麼長時間來重新加載聯繫人
- 3. 重置觸摸在更新中需要太長的時間
- 4. 更新查詢需要太多的時間
- 5. 頁面索引需要太多時間來加載
- 6. magento重新索引需要太多時間
- 7. Android ImageView.setMatrix()和.invalidate() - 重新繪製需要太多時間
- 8. NSUserDefaults - 需要重新加載?
- 9. 當響應太快,需要更新的數據太多時
- 10. 加入和更新需要太長時間
- 11. Neo4J - 加載到圖表需要太多時間
- 12. 小更新需要多長時間?
- 13. JPanel需要多長時間來更新它的高度?
- 14. analogRead需要太多時間
- 15. 重置表單元素無需重新加載頁面
- 16. 在網絡表單上加載大號PDF需要太多時間
- 17. 更新導航無需重新加載
- 18. Google表單在不需要時重新計算單元格
- 19. SL5 + Prism 4.1動態XAP下載需要花費太多時間來加載
- 20. 在手機間隙html頁面需要太多時間來加載
- 21. 多重提交表單無需重新加載
- 22. 表視圖重新加載單元格
- 23. 爲什麼我的圖片需要加載太多時間?
- 24. 硒需要太多的時間加載一個頁面
- 25. AJAX TruClient協議需要更多時間來加載頁面
- 26. 應用程序需要更多時間來加載extjs
- 27. jQuery簡單的負載需要太多的時間來第一次電話
- 28. 谷歌分析需要多少時間來更新目標?
- 29. Swf需要花費太多時間來加載,我該如何加快速度?
- 30. 更新細節後需要重新加載視圖目標C
請顯示一些代碼,以便我們能夠確定在你犯錯的地方。 –
感謝您的回覆....更多的時間在heightForRowAtIndexPath同時計算單個行的高度...當我重新加載表時它需要更多的時間500行高度和不同的高度... –
請發表一些代碼。 –