如何向基于视图的应用程序添加导航控制器? [英] How to add a navigation controller to a view-based application?

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

问题描述

可以向继承自 UIViewController 而不是<$ c $的视图应用程序添加 UINavigationController c> UITableViewController ?

Is it possible to add a UINavigationController to a view application that inherits from UIViewController and not UITableViewController? How is it done?

推荐答案

是的,您可以在任何基于视图的应用程序中使用Navigation控制器,无论是在根级别当您在Xcode中创建基于导航的模板时),或者使用TabBar根或任何根创建基于导航的模板。

Yes, you can have Navigation controllers in any view based application, whether at the Root level (like when you create the Navigation-based template in Xcode) or with a TabBar root, or with any Root.

应用程序显示一系列形式):

One example, presenting a modal view including navigation (used in my app to display a series of forms):

    UIViewController *control = [[MyViewController alloc] initWithNibName: @"MyViewController" bundle: nil];
    UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: control];
    [self presentModalViewController: navControl animated: YES];
    [control release];

在另一个例子中,如果你想在根级别,但没有创建应用程序与导航模板,在AppDelegate的didFinishLaunching(...):

In another example, if you want to have it at the root level, but didn't create the application with the Navigation template, in the AppDelegate's didFinishLaunching(...):

    UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: control];
    [window setRootViewController: navControl];
    [navControl release];

您还可以在Interface Builder中设置它,方法是设置您使用的View控制器UIViewController由UINavigationController替换。)

You can also set it in Interface Builder, by setting up the class of the View controller you use (UIViewController replaced by UINavigationController).

我希望这回答了您的问题(对上一个讨论的遗憾)。

I hope this answers your question (sorry about the previous discussion).

这篇关于如何向基于视图的应用程序添加导航控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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