0

TableViewCell Class

- (void)awakeFromNib {
 //Registering CollectionViewCell
}


- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return [productsData count];
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collectionCell" forIndexPath:indexPath];
    NSDictionary *cellData = [productsData objectAtIndex:[indexPath row]];
    cell.imageView.image = [UIImage imageNamed:[cellData objectForKey:@"image"]];
    return cell;
}

How to call delegate methods of collection view?

pkc456
  • 8,350
  • 38
  • 53
  • 109
Champz
  • 11
  • 3

1 Answers1

1

In your TableViewCell.h file add .

@property (nonatomic, assign) UICollectionView *yourCollectionView;

In your TableViewCell.m file add .

@synthesize yourCollectionView;

in your init method alloc collection view & set delegate & datasource .

yourCollectionView = [UICollectionView alloc] initWithFrame://( your frame) ];

yourCollectionView.dataSource = self;
yourCollectionView.delegate = self;
// set other properties as per tour needs .

[self.contentView addSubview:yourCollectionView];

Add check your delegate methods wotrking fine . hope it helps you .

P.J.Radadiya
  • 1,493
  • 1
  • 12
  • 21
Garry
  • 407
  • 2
  • 15
  • Its working but error is coming "must register a nib or a class for the identifier". So in the above code have i done proper coding for registering cell? – Champz Oct 13 '15 at 07:15
  • in your init method add [yourCollectionView registerClass:[yourcollectionviewcellclass class] forCellWithReuseIdentifier:@"indetifire"]; before allocating collection view. – Garry Oct 13 '15 at 07:20