简体   繁体   中英

How to show the Navigation Bar in an iOS view?

I'm opening a View from the navigationController, using the NVSlideMenuController. However, I haven't been able to show a Navigation Bar (which I definitely need).

I'm not familiar with NavigationControllers and after following a few tutorials, it still isn't clear enough to me how it works.

This is in the AppDelegate application didFinishLaunching:

IntroViewController* introVC = [[IntroViewController alloc] initWithNibName:@"IntroViewController" bundle:nil];
UIViewController *menuViewController = [[MenuViewController alloc] initWithStyle:UITableViewStyleGrouped]; // Your menu view controller
UIViewController *contentViewController = (UIViewController*)introVC; // The initial content view controller

menuViewController.navigationController.navigationBarHidden = false;

NVSlideMenuController *slideMenuController = [[NVSlideMenuController alloc] initWithMenuViewController:menuViewController andContentViewController:contentViewController];

self.window.rootViewController = slideMenuController;
return YES;

I tried adding the code to put the navbarhidden to false and it doesn't seem to work. Is there something else I missed?

Any help is very appreciated!

MyViewController *myViewController = [[MyViewController alloc] init];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];

self.window.rootViewController = navigationController;

This will set the UINavigationController as your root view controller. If you MUST use NVSlideMenuController (which I have 0 experience with but really don't think it is necessary), then you can do the first two lines I gave you, and set the navigationController as the root for the NCSlideMenuController . I would recommend Apple's documentation for UINavigationController, it is an extremely useful thing to know: https://developer.apple.com/LIBRARY/IOS/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM