简体   繁体   English

为什么我需要控制某种UI小部件并将其拖动到代表视图控制器的黄色区域中?

[英]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.

相关问题 什么时候需要使用视图控制器? - When do you need to use a view controller? 我的AppDelegate.h文件中是否需要为项目中的每个视图控制器提供“ @class”声明? - Do I need an '@class' declaration in my AppDelegate.h file for every view controller in my project? 如何在Swift iOS开发中从一个视图控制器到另一个容器视图控制器获取分段控制索引? - How do I get the Segmented Control index from one view controller to another containerview controller in Swift iOS development? 我在顶部有一个带有UIButtons的UI滚动视图。 如何在触摸和拖动按钮时滚动? - I have a UI Scroll View with UIButtons on top. How do i make it scroll when they touch and drag the buttons? 如何在推送的视图控制器下弹出视图控制器? - How do I pop the view controller underneath a pushed view controller? 如何推送根视图控制器? - How do I push root view controller? 我是否需要为UITextField创建一个控制器? - Do I need to create a controller for a UITextField? 我想限制某些视图控制器以在ios6中进行横向显示 - I want to restrict some of the view controller to landscape in ios6 iOS - 如何控制模态视图控制器的大小? - iOS — how do you control the size of a modal view controller? iPhone,为什么以及如何在保留视图控制器的同时更正这些分析仪警告? - iPhone, why and how do i correct these anlyzer warnings while retaining a view controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM