0

[sorry for my weak english]

I have some method to create and show some new view controler (on top of my current view controler level)

- (void) switchToDifficultyMenu
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

 DifficultyMenuController *difficultyMenuController = [[DifficultyMenuController alloc] init];

   NSLog(@"navigation controller %@" , self.navigationController); //navContr is nil

 [self.navigationController pushViewController: difficultyMenuController animated: NO];

 [difficultyMenuController release];
[pool release];  


}

it works when i fire it for example from under tap events on my current view controller, but when i try to call it immediately when my current view controler loads (it is some need for that) id est in its -viewdidLoad the navigationController is nil

how can i make it work, much tnx

0

1 Answer 1

3

Until you don't push your UIViewController into an UINavigationController, the navigationController property will be null. The viewDidLoad method is always called before the push. So in the viewDidLoad, there is no way to access this property.

Sign up to request clarification or add additional context in comments.

2 Comments

much tnx, if so then where is the place I can fire my method, as soon as possible, at the begining of previous viewcontroler creation (i want to see after my first viewcontroler on the stack, the third viewcontroler on the stack (before the second on the stack) and the second after the pop in the third :/ i know that i possibly should rebuild the 'architecture' but the first could by be more quick and easy
In this case, you should try using the viewWillAppear: method. The viewDidAppear: method will still work, but I think it doesn't have the desired effect you would like to have. I think you have 5 minutes to try out both of them and see, which corresponds your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.