UITextView Not Allocating in View
So I have been doing this awhile now and have run into a really strange error. I have a view that co开发者_开发知识库ntains a UITextView, but when I try to set the text after allocating the view, nothing happens. If I stop it and look at the value, it is 0x0, which really doesn't make sense. The components have been declared and connected in IB, so that's not the issue. Here is the part that is giving me problems:
NewView *view = [[NewView alloc] initWithNibName:@"NewView" bundle:[NSBundle mainBundle]];
view.label.text = string1;
view.textView.text = string2;
view.textView.editable = NO;
If I break it there and check the values, that's where it is 0x0. That's why it's not loading, but I can't figure out why it's not working. I have done this tons of times and have never seen this before. Anyone have any Ideas what may be going on?
The solution to this was very simple.
Tejaswi pointed out that the UI components are not initialized until the viewDidLoad: method is executed. So I passed the strings as a varaible and set the field text in the viewDidLoad: method. This worked.
精彩评论