[英][tableView numberOfRowsInSection:0 always returns 0
The data populates, but [tableView numberOfRowsInSection:0]
always returns 0. There is only one section in my table. 填充数据,但[tableView numberOfRowsInSection:0]
始终返回0.我的表中只有一个部分。 What types of things can cause this behavior? 什么类型的东西可以导致这种行为?
If there is only one section always in your table, go with the following coed... 如果表格中只有一个部分,请使用以下编辑...
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
Or in case your number of sections are depending on datasource, you can return the count of your datasource. 或者,如果您的部分数量取决于数据源,您可以返回数据源的计数。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];
Try this. 尝试这个。 It might help you. 它可能对你有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.