当许多行发生更改时,使用 NSFetchedResultsController 禁用 UITableView 的动画
在我的 UIView 中,我有一个 UITableView (UITV),它由 NSFetchedResultsController (NSFRC) 控制。 UIView 位于 UINavigationController 内。
当视图即将加载/显示时,我启动一些后台活动,从远程服务器 (JSON) 获取数据并解析为核心数据。
当解析完成并且线程 NSManagedObjectContext 已合并到主上下文中时,将调用 NSFRC。
问题在于,有时会同时将许多行插入到 Core Data 中,添加大量表格单元格,并且从实际获取和解析完成到显示行,有相当长的延迟。
现在我想知道是否有人知道任何解决方案,例如:
- 将微调器连接到某个“获取的结果控制器这次插入了所有行”(或其他东西)通知/委托调用至少告诉用户“有些东西很快就会出现”?
或者最好的解决方案可能只是在后台获取和处理完成之前不初始化 NSFRC?
谢谢!
In my UIView I've got a UITableView (UITV) which is controlled by an NSFetchedResultsController (NSFRC). The UIView is inside a UINavigationController.
When the view is about to be loaded/displayed I start some background activities which fetch data from a remote server (JSON) and parse into Core Data.
The NSFRC is being called when the parsing is done and the threaded NSManagedObjectContext have been merged into the main context.
The problem is that sometimes many rows are being inserted to Core Data at once, a lot of table cells are being added and there is quite a delay from that the actual fetching and parsing is done, until the rows are being displayed.
Now I wonder if anyone knows of any solution to, for example:
- hook up a spinner to some "fetched results controller inserted all its rows for this time" (or something) notification/delegate call to at least tell the user that "something is going to show up soon"?
Or might the best solution simply be to not initialize the NSFRC until the background fetching and processing is completed?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解您的问题,您可能需要研究
NSFetchedResultsControllerDelegate
方法,此处提供文档:http://developer.apple.com/library/ios/#documentation/CoreData/Reference/NSFetchedResultsControllerDelegate_Protocol/Reference/Reference.html有一些委托方法可用于使用
controllerWillChangeContent:
进行预更改、使用controllerDidChangeContent
进行发布更改以及使用didChangeSection:
和didChangeObject< 进行更改期间/代码>。
我希望它有帮助!
罗格
If I understand your question correctly, you may want to look into the
NSFetchedResultsControllerDelegate
methods, with documentation available here: http://developer.apple.com/library/ios/#documentation/CoreData/Reference/NSFetchedResultsControllerDelegate_Protocol/Reference/Reference.htmlThere are delegate methods available for pre changes with
controllerWillChangeContent:
, post changes withcontrollerDidChangeContent
and during changes withdidChangeSection:
anddidChangeObject
.I hope it helps!
Rog