简体   繁体   中英

Change uilabel text after uiview is loaded

I have a custom UIView subclass. I am loading this through [[NSBundle mainBundle] loadNibNamed:@"" ...] . I have linked all of my outlets properly in Interface Builder but in initWithCoder , my UILabel is 0x0.

Where can I have a method that will call when the IBOutlets will finish initalizing so I can access my UILabel and call setText ?

viewDidLoad, and don't forget to call super

- (void)viewDidLoad
{
   [super viewDidLoad];
   mylabel.text = @"yadayadayada";
}

在控制器的-viewDidLoad方法中初始化UI元素

Wow, found the answer!

- (void)awakeFromNib

Thanks to all that answered anyway!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM