【发布时间】:2023-03-14 13:19:01
【问题描述】:
我创建了一个对 Apple 集合视图示例项目非常简单的集合视图。我在情节提要的视图控制器中有一个集合视图,并在集合视图右上角的集合视图单元格内设置了一个标签。我已将其连接到自定义单元格中的 IBOutlet。以下是相关代码:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.workoutView registerClass:[Cell class] forCellWithReuseIdentifier:@"Cell"];
...
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if (collectionView == self.collView) {
Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
cell.segmentTitle.text = @"some text";
cell.backgroundColor = [UIColor whiteColor];
return cell;
}
return nil;
}
我在segmentTitle.text 部分之后放置了一个断点,并且segmentTitle 始终为空。因此,我在模拟器中看到的是空的白框。我错过了什么?
【问题讨论】:
标签: ios ios6 storyboard uilabel uicollectionviewcell