Halen
Halen

Reputation: 456

Referencing IBOutlets during UICollectionViewCell initialization

I have a custom UICollectionViewCell with an imageView, a textField and a label. I have a skeleton made in Interface Builder. I need to do some more work on the imageView (setting the image and giving it rounded corners) during the initialization process, but I can't do it during initWithCoder: because the outlets aren't set yet. I would like to do that work within the cell class so I can keep those components as private. Is there anyway I can do the work on those components during the initialization process, or do I need to make them public so that my collection view data source can do that work during cellForItemAtIndexPath:?

Upvotes: 0

Views: 354

Answers (1)

rdelmar
rdelmar

Reputation: 104082

Do it awakeFromNib instead of initWithCoder. The outlets wil be set by then.

Upvotes: 3

Related Questions