Tuesday, February 16, 2010

Why viewWillAppear Wasn't Called?

Have several views defined as XIB, work just fine as standalone views and as main views under UITabBar. However they stopped working when added them as subviews under main view in UITabBar (don't ask...)

The problem was that viewWillAppear wasn't called automatically, because I added the views manually under another view. Apple documentation suggests calling the missing function manually - and yet again everything works just fine!

self.myController =
[[MyViewController alloc]
initWithNibName:@"MyViewController" bundle:nil];
[self.mainView addSubview:myController.view];
[self.myController viewWillAppear:YES];

No comments:

Post a Comment