collection 视图单元格中的标签不会显示

Label in collection view cell won't show up

我正在尝试让标签和图像显示在 collection 视图单元格中,但只有图像会是我的代码

header 文件

#import <UIKit/UIKit.h>
#import "ComicMetadata.h"

@interface ComicCell : UICollectionViewCell

@property (nonatomic, retain) UIImageView *page;
@property (nonatomic, retain) UILabel *name;

@end

Body

#import "ComicCell.h"

@implementation ComicCell

- (id)initWithFrame:(CGRect)frame{

self = [super initWithFrame:frame];
if (self){
  self.page = [[UIImageView alloc] init];
  self.name = [[UILabel alloc] initWithFrame:self.bounds];
  self.autoresizesSubviews = YES;

  self.name.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

  self.name.font = [UIFont systemFontOfSize:13];

  self.name.textAlignment = NSTextAlignmentLeft;

  [self.contentView addSubview:self.page];

  [self.contentView addSubview:self.name];

  self.name.text = @"Test";
  }
return self;
}

- (void)layoutSubviews{
  [super layoutSubviews];
  //self.page.frame = self.contentView.bounds;
  self.page.frame = CGRectMake(0, 0, 234, 312);
}

我做错了什么?额外的文本,因为 Whosebug 不喜欢代码与文本的比例

ComicCell初始化frame时,bounds初始化不准确,必须在layoutSubviews中重新设置label的frame。

- (void)layoutSubviews{
    [super layoutSubviews];
    self.page.frame = CGRectMake(0, 0, 234, 312);
    self.name.frame = CGRectMake(0, 0, 234, 312);
}