Data getting lost between 2 ViewDidLoad calls
Inside a UIViewController class, I have a tableView who gets called like this by clicking on a navBar button:
-(IBAction) addButtonPressed:(id)sender {
CreateQuestionController *createQuestionViewController = [[CreateQuestionController alloc] initWithNibName:@"CreateQuestionController" bundle:nil];
[self.navigationController pushViewController:createQuestionViewController animated:YES];
[createQuestionViewController release];
}
This method gets called nowhere else in my code. Well, when I click this navBar button and the view shows up I find out that the ViewD开发者_StackOverflow社区idLoad method gets called twice (which is normal in this case) BUT the data I enter here gets lost. Here's my code:
- (void)viewDidLoad
{
[super viewDidLoad];
textView.text=@"Type your question here";
NSLog(@"Question text:%@", textView.text);
}
Log:
2011-07-11 10:56:35.727 HelpMe[1343:207] Question text:Type your question here
2011-07-11 10:56:35.728 HelpMe[1343:207] Question text:(null)
What's going on? Thank you
Edit: Other symptoms: - Cannot push another view - Cannot change the image of a button
My problem was in my nib file. I deleted my controller and assigned all my outlets to the File's owner
精彩评论