开发者

iPhone - a question about navigationControllers and viewController

开发者 https://www.devze.com 2023-03-18 16:25 出处:网络
I have a project based on Xcode\'s NavigationController template. This template has a navigationController and a RootViewController.

I have a project based on Xcode's NavigationController template. This template has a navigationController and a RootViewController.

From inside thi开发者_StackOverflows RootViewController I push a view and this view pushes a third view. Something like:

NavigationController >> RootViewController >> ViewController 1 >> ViewController 2

Now, from ViewController2 I want to access the navigationController and the navigationController.toolbar.

I know that every viewController has the navigationController property but my question do I have to do something when I push a new viewController so this variable (on the view that is being pushed) will have a valid reference to the correct ViewController or all pushed views will always have a valid reference to the navigationController?

The reason for my question is that I am trying to access the navigationController.toolbar, to make it invisible, and I am having no result.

thanks.


You might want to try -[UINavigationController setToolbarHidden:animated:] to hide the toolbar instead:

[self.navigationController setToolbarHidden:YES animated:YES];

This has always worked for me no matter how deep in the navigation stack my view controller was.


In the entire navigation stack of one UINavigationController object, every view controller's navigationController property has the same value.


The navController is like a box that contains the viewControllers within, with the last one to be pushed shown to the user until it is popped off, when the one below it will come to life again.

This means you can rely on the navController instance always being available from within a controller that was pushed by the navController.

0

精彩评论

暂无评论...
验证码 换一张
取 消