导航控制器 - 如何添加在另一个视图控制器在Xcode? [英] Navigation Controller - How to Add in Another View Controller in Xcode?

查看:389
本文介绍了导航控制器 - 如何添加在另一个视图控制器在Xcode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS编程的新手,但我一点点学习。我有两个nib文件,一个是我的HomeViewController和另一个名为'ReceiptTableViewController'。 HomeVC不应该有一个顶部导航栏,但ReceiptTableVC应该有一个标题和'后面',用户可以滑动回到HomeVC。

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.

我如何去添加这个?我已经将导航控制器拖动到nib文件中我的ReceiptTableVC一侧。

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

我搜索过各种答案,但有些矛盾,因为作者使用不同版本的Xcode,一些从故事板等开始。

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.

任何帮助非常感谢!


  • 我没有使用storyboard

推荐答案

您可以使用此方法来决定您的navigationBar是否显示在viewController中。 self.navigationController setNavigationBarHidden:animated:];

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

在您的AppDelegate

In your AppDelegate

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

然后在 ReceiptTableViewController 的viewDidLoad方法。

Then in your ReceiptTableViewController's viewDidLoad method.

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

这是如何以程序方式声明UINavigationController。你可以试试。

This is how to declare a UINavigationController programly . you can have a try.

这篇关于导航控制器 - 如何添加在另一个视图控制器在Xcode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆