我是UICollectionView的新手。我正在尝试添加两个UILabel到我的自定义UICollectionViewCell
,如下所示。将UILabel添加到自定义UICollectionViewCell不会出现在cellForItemAtIndexPath中
@interface PassCell : UICollectionViewCell
@property (nonatomic) IBOutlet UILabel *titleLabel;
@property (nonatomic) IBOutlet UIButton *infoButton;
@property (nonatomic) IBOutlet UIButton *doneButton;
@property (nonatomic) IBOutlet UILabel *headerTitle;
我已经在Storyboard
UILabel
连接。 但是,当我在CellforITemAtIndexPath
设置headerTitle,headerTitle UILabel
不出现。只有titleLabel可以设置值。
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
PassCell *cell = (PassCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"pass" forIndexPath:indexPath];
cell.titleLabel.shadowColor = [UIColor blackColor];
cell.titleLabel.textColor = [UIColor whiteColor];
cell.titleLabel.shadowOffset = CGSizeMake(0, 1);
cell.titleLabel.text = @"Test";
cell.headerTitle.text // That doesn't appear.
return cell;
}
我的代码有什么问题?
try [cell.contentview addsubview:titlelabel]; – BHUMICA 2014-11-04 05:30:23
我在Storyboard中添加了UILabel。而且我还连接了IBOutLet。但不会出现在cellForItemAtIndexPath中。 – 2014-11-04 05:31:27
在cellforRow.it中以编程方式创建uilabel的作品绝对有效。 – BHUMICA 2014-11-04 05:32:45