Reputation: 545
Is it advisable to set UIFont
of a UILabel
in layoutSubviews
. I am subclassing a UITableViewCell
. We use layoutSubview
to adjust the UIView
frame if required, so I am not sure whether I should go with it.
Also, is there is method like viewDidLoad
, which will be called only once.
I tired to set the font in initWithCoder
, but IBOutlet
of UILabel
is empty in initWithCoder
.
I can set the UILabel
text in cellForRowAtIndexPath
, so connection to this custom UILabel
is correct.
Note:- The cell is initialized from a UIViewController
in UIStoryboard
.
Upvotes: 0
Views: 237
Reputation: 66242
You should only layout your views in layoutSubviews
. UITableViewCell
is a subclass of UIView
, so you can set up your properties here:
- (void) awakeFromNib {
self.myLabel.text = @"my text";
}
Upvotes: 1