简体   繁体   English

命名约定 - uinavigationcontroller 和根视图

[英]naming conventions - uinavigationcontroller and root view

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.我是 xcode 和 iOS 开发的新手,这些天试图了解 uinavigtioncontroller 的工作原理。 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.在我看到的所有示例和教程中(没有一个可以帮助我顺便说一句......也许是新 xcode 的 b/c?),总是提到 RootViewController class。 Now, when I open a new view based app project, i immediately get the app delegate class and another object called: MyProjectViewController.现在,当我打开一个新的基于视图的应用程序项目时,我立即得到应用程序委托 class 和另一个名为:MyProjectViewController 的 object。 So my question is - is this RootViewController that everyone are talking about IS the MyProjectViewController that is created for me automatically?所以我的问题是 - 每个人都在谈论的这个 RootViewController 是自动为我创建的 MyProjectViewController 吗? OR do they open a new class and call it RootViewController?或者他们是否打开一个新的 class 并将其命名为 RootViewController? OR do they just change its name from MyProjectViewController to RootViewController?还是他们只是将其名称从 MyProjectViewController 更改为 RootViewController? (or something else...:)) (或者是其他东西...:))

Thanks for the help!谢谢您的帮助!

There is nothing special with RootViewController. RootViewController 没有什么特别之处。 It is just another view controller.这只是 controller 的另一个视图。 You can have your own eg MyTopViewController as your root view controller.您可以拥有自己的 MyTopViewController 作为您的根视图 controller。

When you use a navigation controller, you navigate through many view controller.当您使用导航 controller 时,您会浏览许多视图 controller。 The fist one in the stack, where you start to navigate is called root view controller.堆栈中的第一个,您开始导航的位置称为根视图 controller。 But RootViewController is just a class name.但 RootViewController 只是一个 class 名称。

Usually, when you create a project, if you open the MainWindow.xib, you can find all the reference to the default created file.通常,当你创建一个项目时,如果你打开 MainWindow.xib,你可以找到所有对默认创建文件的引用。 Even you can change the name of MainWindow.xib.甚至您可以更改 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.如果你打开 {Project-Name}-Info.plist 文件,在你的项目中,你可以找到 main xib 文件的选项,它指的是 MainWindow.xib 文件。 Here you can customize which is the one xib file you want to load at first runtime.在这里,您可以自定义要在第一次运行时加载的一个 xib 文件。

In xcode 4 - when you create a navigation controller project you get a RootViewController class.h/.m/.xib created for you.在 xcode 4 中 - 当您创建导航 controller 项目时,您将获得为您创建的 RootViewController class.h/.m/.xib。

You can add these to the basic project type, but that is what the tutorials are referring to.您可以将这些添加到基本项目类型中,但这就是教程所指的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM