Navigation Controller - How to Add in Another View Controller in Xcode?

隐身守侯 提交于 2019-12-24 18:12:52

问题


I'm relatively new to iOS programming but I'm learning bit by bit. I've got two nib files, one is my HomeViewController and the other is called 'ReceiptTableViewController'. The HomeVC should not have a top nav bar but the ReceiptTableVC should, with a title and 'back' where the user can swipe to go back to HomeVC.

How would I go about adding this? I've dragged the Navigation Controller to the side of my ReceiptTableVC in the nib file.

I've searched for various answers but some contradict each other as the authors use different versions of Xcode, and some start with storyboards, etc.

Any help is much appreciated!

  • I haven't used storyboard

回答1:


You can use this method to decide whether your navigationBar show or not in your viewController.[self.navigationController setNavigationBarHidden: animated:];

In your AppDelegate:

UINavigationController *naviController = [[UINavigationController alloc] initWithRootViewController:homeController];
naviController.navigationBarHidden = YES; //set home controller navigation bar hidden.
self.window.rootViewController = naviController;

Then in your ReceiptTableViewController's viewDidLoad method:

[self.navigationController setNavigationBarHidden:NO animated:NO]; // show the navigation bar.

This is how to declare a UINavigationController programmatically. You can have a try.



来源:https://stackoverflow.com/questions/20831791/navigation-controller-how-to-add-in-another-view-controller-in-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!