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.

有帮助吗?

解决方案

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";    
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top