CollectionViewのカスタムセルに何も表示ができない
現在ViewControllerにUICollectionViewを二つ置き、一つのUICollectionViewはカスタムセルを使っています。カスタムセルにはUILabelを一つ置いており、これに文字列を入れて表示させようとしているのですが、セルには何も表示されません。カスタムセルのUIを定義しているxibファイルの名前は「WeekPlanCell」で、nibWithNibNameメソッドの引数と一致しています。WeekPlanCellというクラスを作り、そのヘッダファイルにWeekPlanCell.xibにあるUILabelを紐付けています。そしてStoryboardのCollection Reusable Viewのidentifierには「afterDayCell」と入力しており、cellForItemAtIndexPathのdequeueReusableCellWithReuseIdentifierの引数の文字列と一致しています。
また、Storyboardのカスタムセルを用いたUICollectionViewのセルのCustom ClassのClassには「WeekPlanCell」と入力しています。
上記の手順でどこが間違っているのでしょう?
どなたか分かる方がいれば教えていただきたいです。
すみませんが、よろしくお願いします。
- (void)viewDidLoad {
[super viewDidLoad];
[self initCustomCell];
}
- (void)initCustomCell {
UINib *nib = [UINib nibWithNibName:@"WeekPlanCell" bundle:nil];
[self.collectionView registerNib:nib forCellWithReuseIdentifier:@"afterDayCell"];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
if (collectionView == self.collectionView) {
return 1;
} else {
return 1;
}
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if (collectionView == self.collectionView) {
return 1;
} else {
return 6;
}
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell;
if (collectionView == self.collectionView) {
cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@"todayCell" forIndexPath:indexPath];
} else {
cell = [self.afterDayCollectionView dequeueReusableCellWithReuseIdentifier:@"afterDayCell" forIndexPath:indexPath];
WeekPlanCell *weekPlanCell = (WeekPlanCell*)cell;
weekPlanCell.layer.borderWidth = 0.4f;
weekPlanCell.layer.borderColor = [UIColor blackColor].CGColor;
weekPlanCell.label.text = @"book";
}
return cell;
}