开发者

Assign string to UITextView

I am trying to load text into a textview. This seems simple enough:

box.text = @"hello";
NSLog(@"Box.text contains: %@", box.text);

The problem is that this NSLog just keeps printing null. (I have IBOutlet UITextView *box declared.) I imagine that since box.text is null, that's why nothing is actually showing up in the UITextVi开发者_JAVA百科ew either.

Anyone know what's going wrong?

Thanks a lot!


If you're calling box.text from your controller's init method, your IBOutlet hasn't been loaded from the nib file yet – so box is still pointing to nil, and the text assignment is going nowhere. You'll need to wait until viewDidLoad or later to successfully access the properties of your IBOutlet.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜