简体   繁体   English

您如何查看或操纵创建的视图背后的代码?

[英]How do you see or manipulate the code behind the views you create?

I'm trying to figure how to look at or manipulate the code behind views I've created in tutorial applications I've copied. 我试图弄清楚如何在复制的教程应用程序中创建的视图后查看或操纵代码。

I understand that you are supposed to "control" the views using a view controller. 我了解您应该使用视图控制器来“控制”视图。 The part that's confusing me is that when I follow the tutorials, I'm clicking on my view objects, setting the delegate, but I don't see where that is acutally happening in the code. 使我感到困惑的部分是,当我按照教程进行操作时,我单击的是视图对象,设置了委托,但是我看不到代码中的实际位置。 Are you able to see the code that makes up a view or is that totally hidden from you? 您是否能够看到组成视图的代码,或者对您完全隐藏了这些代码?

You mean when you are dragging views around visually when you open a nib? 您是说打开笔尖时在视觉上拖动视图吗?

The objects you create and the connections you make are saved to an XML file. 创建的对象和建立的连接将保存到XML文件中。 When Xcode builds your application, these are then converted to a more efficient binary file format. 当Xcode构建您的应用程序时,它们随后将转换为更有效的二进制文件格式。

When your application runs, the binary file is read, and the objects described within are instantiated. 当您的应用程序运行时,将读取二进制文件,并实例化其中描述的对象。 Where connections are made, the nib loading part of the platform uses Key-Value Coding to set the outlets and properties on related objects, most often the nib owner. 在进行连接的地方,平台的笔尖加载部分使用键值编码来设置相关对象(通常是笔尖所有者)上的出口和属性。

You can see the XML representation of your views by right-clicking on the nib in the project navigator panel on the left-hand side, then selecting Open As | 通过右键单击左侧项目导航器面板中的笔尖,然后选择“ 打开为| |打开” ,可以查看视图的XML表示形式。 Source Code . 源代码

You need to go through Apple's " Your First iOS App " guide, and read it, do it, and reread it until just that basic tutorial sinks in. 您需要仔细阅读Apple的“ 您的第一个iOS应用 ”指南,然后阅读,执行并重新阅读,直到基本教程陷入其中。

If you use Interface Builder to create a view (it will create that view in a nib file), you will connect that with a view controller that will consist of an interface file and an implementation file. 如果使用Interface Builder创建视图(它将在nib文件中创建该视图),则将其与包含接口文件和实现文件的视图控制器连接。 Within these files you will place code by which you will reference those components in the view, and you will also code methods that will give you behaviors and operations that can be triggered or can manipulate components and data of that (or other) views. 在这些文件中,您将放置用于引用视图中那些组件的代码,还将对将为您提供可以触发或可以操纵该(或其他)视图的组件和数据的行为和操作的方法进行编码。

You just need to really digest Apple's documentation better. 您只需要更好地消化Apple的文档即可。 They have wonderful guides to help you. 他们有很棒的指南来帮助您。

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

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