我已经尝试了所有的方法,如运行在主线程等.... 但他们都没有工作.. 我的表有超过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行高度和不同的高度... –
请发表一些代码。 –