[英]Why do I need to control-drag some kind of UI-widgets into yellow sphere representing the view controller?
I'm a newbie and am learning the iOS-dev through reading the official tutorial Your First iOS App . 我是新手,正在通过阅读官方教程Your First iOS App学习iOS-dev。
While I don't quite understand the behind meaning of control-dragging the text-filed into the view controller represented by a yellow sphere icon. 虽然我不太了解,但将控件拖到黄色球形图标代表的视图控制器中的背后含义是。
I mean it's easy to follow but hard to know the behind reason. 我的意思是易于理解,但很难知道背后的原因。
I checked the code after the operation and found nothing is added. 我在操作后检查了代码,发现没有添加任何内容。
Could someone help to figure out why? 有人可以帮忙找出原因吗? TIA. TIA。
well, I posted some description the tutorial says to help my question could be understood exactly. 好吧,我在教程中发布了一些说明,以帮助我的问题得到准确的理解。
"In the view, Control-drag from the text field to the yellow sphere in the scene dock (the yellow sphere represents the view controller object). When you release the Control-drag, you should see something like this: [sorry image's not allowed to upload for now] . Select delegate in the Outlets section of the translucent panel that appears." “在视图中,按住Control键从文本字段拖动到场景底座中的黄色球体(黄色球体表示视图控制器对象)。释放Control-拖动时,应该看到类似以下内容: [对不起,图像没有允许暂时上传] 。在显示的半透明面板的“出口”部分中选择代理。”
The best way to think about it is, that what you create in Interface Builder has to be linked to your code. 最好的考虑方法是,必须将在Interface Builder中创建的内容链接到您的代码。 A .xib file is really just a complicated XML document. .xib文件实际上只是一个复杂的XML文档。 By linking the .xib to the controller it will write code in the XML linking it to the code. 通过将.xib链接到控制器,它将在XML中编写代码,从而将其链接到代码。 otherwise when the .xib and your source code is compiled, the compiler won't link the two entities. 否则,在编译.xib和您的源代码时,编译器将不会链接这两个实体。
Hope this helps 希望这可以帮助
By control-dragging, we create connections between objects/views in the nib (.xib) file to an action (IBAction) or an outlet (IBOutlet) in View Controller. 通过控制拖动,我们在nib(.xib)文件中的对象/视图之间建立了到View Controller中的动作(IBAction)或插座(IBOutlet)的连接。
Nib files (.xib) has responsibility to establish all connections (actions and outlets). Nib文件(.xib)负责建立所有连接(动作和出口)。 There will be nothing added to your Controller code to reflect the connections. 您的控制器代码中不会添加任何内容来反映连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.