使用NSFetchedResultController如何确保只显示100行
request.fetchLimit = 100;
request.fetchBatchSize = 100;
是否真的使用该函数通过 NSFetchedResultsControllerDelegate 来限制 tableView 的行数?
但问题是..有时表会显示超过 100 行,但是当我更改页面并返回表时,表将仅显示 100 行,这是怎么回事?我不希望表格显示超过 100 个。
提前谢谢您。
另一种方法是
更新,
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.FetchController sections] objectAtIndex:section];
CalledRowCountingNotYetCallRowForSection=true;
[self.tableViewA setBounces:YES];
if([sectionInfo numberOfObjects]>100){
//[Timer searchCriteriaChanged];
CLog(@"Something Wrong This NumberOfRow: %d", [sectionInfo numberOfObjects]);
}
else{
}
return [sectionInfo numberOfObjects];
以便当 numberOfObjects 大于 100 时,行数变为 100。但是,这会干扰
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
那么你该怎么做呢?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过覆盖表视图数据源的 numberOfSectionsInTableView 和 numberOfRowsInSection 函数(分别返回 1 和 100)来限制可用行数。
您是否使用SQLStore作为表的基础?根据苹果文档( http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSFetchRequest_Class/NSFetchRequest.html#//apple_ref/doc/c_ref/NSFetchRequest ),fetchLimit 仅适用于 SQL 存储。
You could limit the amount of available rows by overriding the numberOfSectionsInTableView and numberOfRowsInSection functions of your table view data source, returning 1 and 100, respectively.
Are you using a SQLStore as base for your table? According to apple documentation ( http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSFetchRequest_Class/NSFetchRequest.html#//apple_ref/doc/c_ref/NSFetchRequest ), fetchLimit does only work for SQL stores.