命名约定 - uinavigationcontroller 和根视图
这可能是我在这里问过的最愚蠢的问题,但我似乎无法理解这一点。我是 xcode 和 iOS 开发的新手,这些天试图了解 uinavigtioncontroller 的工作原理。在我看到的所有示例和教程中(顺便说一句,没有一个可以帮助我......也许是新 xcode 的 b/c?),总是提到 RootViewController 类。现在,当我打开一个新的基于视图的应用程序项目时,我立即获得应用程序委托类和另一个名为:MyProjectViewController 的对象。所以我的问题是 - 每个人都在谈论的 RootViewController 是自动为我创建的 MyProjectViewController 吗?或者他们是否打开一个新类并将其命名为 RootViewController?或者他们只是将其名称从 MyProjectViewController 更改为 RootViewController ? (或其他...:))
感谢您的帮助!
This may be the silliest question i have ever asked here, but i just can't seem to understand this. I am new to xcode and iOS development, and these days trying to learn how uinavigtioncontroller works. In all the examples and tutorials that i see (none of which could help me btw...maybe b/c of the new xcode?), there is always a mention of a RootViewController class. Now, when I open a new view based app project, i immediately get the app delegate class and another object called: MyProjectViewController. So my question is - is this RootViewController that everyone are talking about IS the MyProjectViewController that is created for me automatically? OR do they open a new class and call it RootViewController? OR do they just change its name from MyProjectViewController to RootViewController? (or something else...:))
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
RootViewController 没有什么特别的。它只是另一个视图控制器。您可以拥有自己的(例如 MyTopViewController)作为根视图控制器。
当您使用导航控制器时,您可以在许多视图控制器中导航。堆栈中的第一个控制器(您开始导航的位置)称为根视图控制器。但 RootViewController 只是一个类名。
通常,当您创建项目时,如果打开MainWindow.xib,您可以找到所有对默认创建文件的引用。甚至您可以更改 MainWindow.xib 的名称。
如果你打开{Project-Name}-Info.plist文件,在你的项目中,你可以找到main xib文件的选项,它指的是MainWindow.xib文件。您可以在此处自定义要在第一次运行时加载的 xib 文件。
There is nothing special with RootViewController. It is just another view controller. You can have your own e.g. MyTopViewController as your root view controller.
When you use a navigation controller, you navigate through many view controller. The fist one in the stack, where you start to navigate is called root view controller. But RootViewController is just a class name.
Usually, when you create a project, if you open the MainWindow.xib, you can find all the reference to the default created file. Even you can change the name of MainWindow.xib.
If you open the {Project-Name}-Info.plist file, in your project, you can find an option for main xib file, which refers to the MainWindow.xib file. Here you can customize which is the one xib file you want to load at first runtime.
在 xcode 4 中 - 当您创建导航控制器项目时,您会获得为您创建的 RootViewController 类 .h/.m/.xib。
您可以将它们添加到基本项目类型中,但这就是教程所指的内容。
In xcode 4 - when you create a navigation controller project you get a RootViewController class .h/.m/.xib created for you.
You can add these to the basic project type, but that is what the tutorials are referring to.