views:

38

answers:

1

I noticed that this problem discussed elsewhere, and I've tried a number of solutions such as adding:

- (void)navigationController:(UINavigationController *)navigationController 
   willShowViewController:(UIViewController *)viewController animated:(BOOL)animated 
{
    [viewController viewWillAppear:animated];
}

Another solution is to call them manually!

The problem is, in both cases, that when i load modal view controller in the view, things appear to work normally, and this results in calling the viewWillAppear twice!

Why it is working when I load the modal view controller? and is there a better solution to this?

+1  A: 

You can see this article, I think it is the same problem as yours.

Toro
I'm using navController pushViewController, yet it dose not result in calling viewWillAppear at the begging, but it call it when i load a modal view controller, and the views behave as expected afterward!
Generally, I will use [self.navigationController pushViewController:childView], not the navController from [UIApplication sharedApplication].navController. Sometimes, they are not the same navigationController.
Toro
Yes I'm using that, still viewWillAppear never been called till I load a modal view controller! Please note that I have UITabBarController designed in the IB, with the controller responsible for creating the UINavigationController added also in the IB.
To initialize the controllers, i was using [self.view addSubview:navController.view], I removed it and extends UINavigationController, and called [self pushViewController:someViewController animated:NO] instead, and It did work! Thanx for the help!