Ios 当tableview位于collectionview单元格内时,未调用tableview数据源和委托

Ios 当tableview位于collectionview单元格内时,未调用tableview数据源和委托,ios,objective-c,iphone,uitableview,ios8.3,Ios,Objective C,Iphone,Uitableview,Ios8.3,我在collectionviewcell中放置了一个uitableview,并在collectionviewcell类中进行了如下编码。但是没有调用datasource和delegate方法。有什么可以帮助我解决这个问题吗 - (id)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { arrayMenuAlerts=[NSMutableArray arrayW

我在collectionviewcell中放置了一个uitableview,并在collectionviewcell类中进行了如下编码。但是没有调用datasource和delegate方法。有什么可以帮助我解决这个问题吗

- (id)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super initWithCoder:aDecoder]) {

        arrayMenuAlerts=[NSMutableArray arrayWithObjects:@"Suri",@"John",@"Phillip",@"Sachin", nil];
        [self.contentView addSubview:tableView];
        tableView.dataSource=self;
        tableView.delegate=self;
    }
    return self;
}
- (void)awakeFromNib {

    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    tableView.dataSource=self;
    tableView.delegate=self;
}

这是因为在init方法上还没有创建对象“self”。您可以将tableView数据源和委托放在另一个方法中。和我一样

@synthesize tableview;
NSMutableArray *arrayMenuAlerts;

- (void)drawRect:(CGRect)rect{
    arrayMenuAlerts = [NSMutableArray arrayWithObjects:@"Suri",@"John",@"Phillip",@"Sachin", nil];
    tableview.dataSource = self;
    tableview.delegate = self;
    [tableview reloadData];
}

- (id)initWithCoder:(NSCoder *)aDecoder {
    return [super initWithCoder:aDecoder];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [arrayMenuAlerts count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    cell.textLabel.text = arrayMenuAlerts[indexPath.row];
    return cell;
}

是否设置了collectionview的数据源和委托方法?
tableView
是IBOutlet?是的tableView是ib outlet,我已为collection view设置了datasource、delegate。tableView位于collectionview单元格内。但未从数据源返回任何数据