Wie implementiere ich Delegate- und Datenquellenmethoden für UICollectionView, wenn es sich in einer benutzerdefinierten TableViewCell in iOS befindet? Ziel C

Hinweis: Ich möchte keine Bibliotheken von Drittanbietern verwenden.

Ich habetableview mit mit einem benutzerdefiniertentable view cell (Tabellenansicht funktioniert einwandfrei).etzt imtable view cell Ich möchte ein @ implementiercollection view. Nun ist mein Problem, wo soll ich das @ implementierdelegate Methoden unddata source -Methoden für die Sammlungsansicht, die sich im @ befindcustom table view cell. unten ist was ich ausprobiert habe.

Tabel View Controller-Implementierung

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    FirstTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tvcell"];

    return cell;
}

funktioniert richti

Jetzt in diesemFirstTableViewCell da ist eincollection view.

Dies ist meine FirstTableViweCell.h-Datei

#import <UIKit/UIKit.h>

@interface FirstTableViewCell : UITableViewCell<UICollectionViewDelegate,UICollectionViewDataSource>
@property (weak, nonatomic, nullable) IBOutlet UICollectionView *insideCollectionView;

@property (strong, nonnull,nonatomic) NSArray *mycollectionData;
- (void)setColletionData :(nonnull NSArray *)collectionData;

@end

und das ist meine FirstTableViewCell.m-Datei

#import "FirstTableViewCell.h"

@implementation FirstTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.insideCollectionView.delegate = self;

    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setColletionData:(NSArray *)collectionData
{
    self.mycollectionData = collectionData;
    [self.insideCollectionView reloadData];
}


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

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *ccell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cvcell" forIndexPath:indexPath];
    return ccell;
}

@end

folgende Methode

- (void)setColletionData:(NSArray *)collectionData
    {
        self.mycollectionData = collectionData;
        [self.insideCollectionView reloadData];
    }

Ich habe das @ gesetarray zumcollectionView, imcellforrowatindexpath imtableview

So was ist der richtige Weg, um @ zu implementierDataSource undDelegate Methoden für dasCollectionView das ist in derCustom Table View Cell.