简体   繁体   English

[tableView numberOfRowsInSection:0始终返回0

[英][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.

相关问题 &#39;NSInvalidArgumentException&#39;testViewController tableView:numberOfRowsInSection - 'NSInvalidArgumentException' testViewController tableView:numberOfRowsInSection -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)部分? - -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section? ReloadData不会触发tableView:numberOfRowsInSection: - ReloadData doesn't fire tableView:numberOfRowsInSection: UITableView-&gt; numberOfRowsInSection:(NSInteger)节返回错误的值 - UITableView -> numberOfRowsInSection:(NSInteger)section returns wrong value 在不使用&#39;numberOfRowsInSection&#39;委托方法iphone sdk的情况下到达表视图的末尾 - Reach the end of the tableview without using 'numberOfRowsInSection' delegate method iphone sdk &#39;NSInvalidArgumentException&#39;-[UIViewController tableView:numberOfRowsInSection:]-无法识别的选择器已发送到实例 - 'NSInvalidArgumentException' - [UIViewController tableView:numberOfRowsInSection:] - unrecognized selector sent to instance 表格视图中的“ EXEC_BAD_ACCESS”,“ [[TasksPageViewController tableView:numberOfRowsInSection:]” - 'EXEC_BAD_ACCESS' in Table View, “[TasksPageViewController tableView:numberOfRowsInSection:]” TableView的内容未显示为“ tableView:numberOfRowsInSection:]:无法识别的选择器已发送到实例” - TableView`s content does not appear “tableView:numberOfRowsInSection:]: unrecognized selector sent to instance” 在核心数据完成处理程序返回之前调用了UITableView numberOfRowsInSection? - UITableView numberOfRowsInSection called before Core Data completionHandler returns? NSInvalidArgumentException tableView:numberOfRowsInSection错误…但是我没有使用选项卡式视图,也没有使用过Interface Builder - NSInvalidArgumentException tableView:numberOfRowsInSection error…but I am not using a tabbed view and I haven't used the Interface Builder at all
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM