如何在不创建子类的情况下获得 NavigationController 功能?
所以我的应用程序的核心是一个标签栏。 3 个选项卡中的每一个都有一个 UINavigationController 子类。每个都有不同类型的表格,当点击一行时,会显示详细信息等。
我目前有 3 个独立的 UINavigationController 子类,每个选项卡一个。然后,当按下新选项卡时,将推动表格的控制器。
我刚刚读到您不应该继承 UINavigationController 的子类。我没有重写任何 UINavigation Controller 的功能,但我在 viewDidLoad 中重写它的 UIViewController 功能。老实说,仅此而已。这看起来很愚蠢,但我不清楚如何在不继承我所拥有的方式的情况下获得导航控制器功能。
那么我应该如何拥有一个我没有子类化的 UINavigationController 呢?选择选项卡时应该采取什么方法来切换视图?
我几乎是一个菜鸟。如果我只覆盖 viewdidload,Apple 会拒绝我的应用程序对 UINavigationController 进行子调用吗?
我听人们说不要子类化 UINavigationController,而是“以模态方式呈现它”。我已经使用了一点模式演示,但老实说我不太明白它是如何应用的......
感谢您的帮助!
So my app's core is a tab bar. In each of 3 tabs is a UINavigationController subclass. Each one has a different type of table in it, which when a row is tapped, a detail is shown etc.
I currently have a 3 separate subclasses of UINavigationController, one for each tab. Then when a new tab is pressed, the table's controller is pushed.
I just read that you're not supposed to subclass UINavigationController. I'm not overriding any of UINavigation Controller's functionality, but I am overriding it's UIViewController functionality in viewDidLoad. Honestly that's just about it. It seems pretty silly, but Im unclear on how to get the Navigation Controller functionality without subclassing the way I have.
So how am i supposed to have a UINavigationController that I don't subclass? What is the approach that you're supposed to take to switch out the views when a tab is selected?
I'm pretty much a noob. Will Apple reject my app for subcalssing UINavigationController if im only overriding viewdidload?
I've heard folks say not to subclass UINavigationController, and instead 'present it modally.' I have used modal presentation a little bit, but I honestly dont' quite get how it would apply...
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你在 viewDidLoad 中做什么?在根视图控制器中而不是在导航控制器中执行它怎么样?
PS 我认为苹果不会拒绝你的应用程序子类化 UINavigationController。
What are you doing in
viewDidLoad
? What about do it in root view controller, not in navigation controller?P.S. I think Apple will not reject your app for subclassing UINavigationController.
您应该使用类别来添加类似的额外功能。它看起来像这样:
您可以将其添加到初始化导航控制器的文件底部
有关类别的更多信息(在底部): http://cocoadevcentral.com/d/learn_objectivec/
You should use categories to add extra functionality like that. It would look something like this:
You can add this to the bottom of the file that initializes the navigationcontroller
More info about categories (at the bottom): http://cocoadevcentral.com/d/learn_objectivec/