IOS: cellFowRow not called for UITableView contained in UICollectionView

My application contains a UICollectionView in which each cell contains a UITableView. The table view method of the number of rows is called correctly, but the cellForRow method is never called. Here is the relevant code:

Setting table views (in boot mode):

[self.collectionView registerNib:[UINib nibWithNibName:@"OrganizationCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"OrganizationCollectionCell"];


    tableViews = [[NSMutableArray alloc] initWithCapacity:recipOrgs.count];

    for (NSDictionary *orgDict in recipOrgs) {

        int index = [recipOrgs indexOfObject:orgDict];


        OrganizationTableView *tableView = [[OrganizationTableView alloc] initWithFrame:collectionView.frame];

        tableView.index=index;
        tableView.parentCon=self;
        tableView.dataSource=tableView;
        tableView.delegate=tableView;

        [tableViews addObject:tableView];

    }

CollectionView cellForItem:

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"cellForItem CollectionView");
    OrganizationCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"OrganizationCollectionCell" forIndexPath:indexPath];

    if (cell==nil) {
        NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"OrganizationCollectionCell" owner:self options:nil];
        cell = [objects objectAtIndex:0];
    }

    OrganizationTableView *tv = [tableViews objectAtIndex:indexPath.row];
    if (tv.orgAlerts==nil) {
        [tv getAlerts];
    }

    cell.tableView=tv;
    cell.tableView.frame=collectionView.frame;
    NSLog(@"%f %f",cell.tableView.frame.size.height,cell.tableView.frame.size.height);

    return cell;

}

GetAlerts method:

-(void)getAlerts{

    orgAlerts = [[NSArray alloc] init];
    NSString *orgID = [[parentCon.recipOrgs objectAtIndex:index] objectForKey:@"id"];

    [[EDAPIStore sharedStore] getAlertsForOrganizationWithID:orgID WithCompletion:^(NSArray *alerts, NSError *error) {

        if (alerts) {

             orgAlerts = alerts;
            [self reloadData];
        }else{
            NSLog(@"%@",error.localizedDescription);
        }

    }];
}

OrganizationTableView numberOfRowsMethod:

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    NSLog(@"number of rows");
    NSLog(@"orgAlerts.count: %d",orgAlerts.count);
    if (orgAlerts.count==0) {

        return 1;
    }else{
        return orgAlerts.count;
    }

I checked that numberOfRows returns the correct number (about 30), but the cellForRow method is never called. Collection cell cells and table cells are defined in their own xib.

+4
source share
1

dataSource delegate viewDidLoad, collectionView:cellForItemAtIndexPath: UITableView UICollectionViewCell dataSource delegate. , iOS UITableViewCell, UICollectionViewCell. , , UITableViewController, UITextField UITableView, cellForRowAtIndexPath:.

, , , , UITableView . "prototype", UITableView . NSArray . , - .

0

Source: https://habr.com/ru/post/1532831/


All Articles