开发者

[tableView numberOfRowsInSection:0 always returns 0

开发者 https://www.devze.com 2023-03-26 07:55 出处:网络
The d开发者_开发百科ata populates, but [tableView numberOfRowsInSection:0] always returns 0. There is only one section in my table. What types of things can cause this behavior?If there is only one se

The d开发者_开发百科ata populates, but [tableView numberOfRowsInSection:0] always returns 0. There is only one section in my table. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消