UINavigationController从头开始? [英] UINavigationController from scratch?

查看:50
本文介绍了UINavigationController从头开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行良好的基于​​视图的应用程序.(换句话说,我不会从基于导航的应用程序模板开始.)

I have a view based app that works well. (In other words, I'm not going to start over with a Navigation-Based App template.)

这是一个让人身临其境的应用程序,我试图添加一个表视图,当按下按钮时,该表视图会在新视图中加载.

It's an immersive app of sorts and I'm trying to add a Table View that loads in a new view when a button is pressed.

加载笔尖部分是可行的,但是我似乎无法将导航控制器添加到新视图中.我想在顶部看到一个带有完成按钮和编辑按钮的导航栏.另外,我希望表视图条目为空.

The loading the nib part works, but I can't seem to be able to add a navigation controller to the new view. I want to see a navigation bar on top with a done button and an edit button. Also, I want to the Table View entries to be empty.

  • 我添加了一个新文件,如下所示: File->新文件->UINavigationController子类.我检查了UITableViewController子类和使用XIB作为用户界面.
  • I added a new file like so: File-> New File -> UINavigationController subclass. I checked the UITableViewController Subclass and With XIB for user interface.

将视图拉起时,我所看到的只是一个空白的表视图.我可以在视图控制器中自定义内容.

All I see when the view is pulled up is a blank Table View. I am able to customize things in the view controller.

如何使表格显示导航栏并可以对其进行编辑?我在这里需要一些指导.

What can I do to make the table show a navigation bar and be editable? I need some direction here please.

我正在使用最新的公共SDK.(XCode 3.2.2)

I'm working with the latest Public SDK. (XCode 3.2.2)

推荐答案

导航栏通常带有导航控制器,而不是带有表视图控制器.

The navigation bar usually comes with a navigation controller, not with the table view controller.

您可以手动添加导航栏,但是这需要更改表视图,才能将其更改为仅带有表视图的常规视图,并将表视图控制器更改为手动的常规视图控制器处理表视图的东西.

You can add the navigation bar manually, but that will require altering the table view, to change it to just a regular view with a table view inside of it, and changing your table view controller to be a regular view controller that manually handles the table view stuff.

更简单的替代方法是在显示表视图控制器之前将其包装在导航控制器中.像这样:

The simpler alternative is to wrap your table view controller inside of a navigation controller before you display it. Something like:

MyTableViewController *myViewController = [[MyTableViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
[myViewController release];

//Now display navigationController instead of myViewController, using something like:
[self presentModalViewController:navigationController animated:YES];

这篇关于UINavigationController从头开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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