My code goes like this:
if (messageBox == nil) {
messageBox = [[MessageBoxController alloc] initWithNibName:@"MessageBoxView" bundle:nil];
}
[messageBox.MessageLabel setText: someString];
[self presentModalViewController:messageBox animated:YES];
However, the very first time the above logic is run (and messageBox is in fact nil and gets initiated) then the new label text (someString) will not show.
The text will show properly the following times I run this method however (and yes, it shows the latest ‘someString’. Not the instance from the last time I called the method).
I tried [messageBox.view setNeedsDisplay] right after setting the label text but that doesn’t help either. In the messageBox viewDidLoad method I also set [self.MessageLabel setText: self.MessageLabel.text] just in case there were some async initialisation or what have you.
Why doesn’t the new label text display the first time calling this method?
The reason is
UILabelwillnotbeloadedand before that u r setting text.