I have the following code for my UICollectionViewCell
@property (strong, nonatomic) IBOutlet UIImageView *storyImage;
@property (strong, nonatomic) IBOutlet UILabel *titleLabel;
@property (strong, nonatomic) IBOutlet UILabel *descriptionLabel;
@end
@implementation Story
@synthesize storyImage;
@synthesize titleLabel;
@synthesize descriptionLabel;
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.descriptionLabel];
[self.contentView addSubview:self.storyImage];
[self.titleLabel setFont:[UIFont fontWithName:kProximaNovaBold size:15]];
[self.descriptionLabel setFont:[UIFont fontWithName:kProximaNova size:13]];
[self.descriptionLabel setTextColor:[UIColor colorWithWhite:140/255.f alpha:1.0]];
self.descriptionLabel.frame = CGRectIntegral(self.descriptionLabel.frame);
self.descriptionLabel.center = roundedCenterPoint(self.descriptionLabel.center);
}
return self;
}
but for some reason it’s not setting up the property. I’d have to move it out of the init method and put it inside a separate method and call this after calling:
dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath
and then it would work. Any idea why?
You want to be doing this stuff in
awakeFromNib:when everything from the nib has actually been loaded and connectedFrom the docs for NSObject UIKit Additions