xcode 无法设置参考出口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27005221/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:12:21  来源:igfitidea点击:

Unable to Set Referencing Outlet

iosobjective-cxcodeiboutlet

提问by vfvfvfvfvfvfvfvfv

I am unable to set a referencing outlet for a text field I have created. I am trying to do this via Ctrl-Drag. Can anyone advise? I have set the delegate as the View Controller. In general, I only have one view which is populated with a few text fields and I have written the following code for the ViewController.h which is what I'm trying to set up as a Referencing Outlet:

我无法为我创建的文本字段设置引用出口。我正在尝试通过 Ctrl-Drag 执行此操作。任何人都可以建议吗?我已将委托设置为视图控制器。通常,我只有一个视图,其中填充了几个文本字段,并且我为 ViewController.h 编写了以下代码,这是我尝试将其设置为引用插座的内容:

@property (weak, nonatomic) IBOutlet UITextField *userIDText;

回答by nhgrif

First, make sure the control you're dragging from is the same class as the outlet (in this case, UITextField) or it could be a subclass of that class.

首先,确保您从中拖动的控件与插座属于同一类(在本例中为UITextField),或者它可能是该类的子类。

Second, make sure control's parent view is a subclass of the file you're dragging to.

其次,确保控件的父视图是您要拖动到的文件的子类。

Third, make sure the file you're dragging to is saved. This is the most common problem I run into. Go to the source file you're dragging to and push Cmd+S to save.

第三,确保您要拖动到的文件已保存。这是我遇到的最常见的问题。转到您要拖动到的源文件,然后按 Cmd+S 进行保存。

Fourth, when in doubt, Cmd+Shift+K to clean, Cmd+B to build, then try again. If that still doesn't work, restart Xcode. And if it's still not working, go back through the checklist.

四、当有疑问时,Cmd+Shift+K 进行清理,Cmd+B 进行构建,然后再试一次。如果这仍然不起作用,请重新启动 Xcode。如果它仍然不起作用,请返回检查清单。

回答by oabarca

In my case, to be able to create a referencing outlet,

就我而言,为了能够创建一个引用出口,

  1. I had to open the Storyboard.
  2. Click on the top View Controller element (left panel in the Storyboard)
  3. In the Identity Inspector (right panel), I had to select from the list my custom view controller class before I could drag and create the referencing outlet in it.
  1. 我不得不打开故事板。
  2. 单击顶部的视图控制器元素(故事板中的左侧面板)
  3. 在 Identity Inspector(右面板)中,我必须从列表中选择我的自定义视图控制器类,然后才能在其中拖动和创建引用出口。

回答by Hideyasu.T

In my cace,(swift3) 1.right click on the storyboard. 2.Ctrl-Drag from black window and ReferencingOutlet to View on the storyboard. enter image description here

在我的情况下,(swift3) 1.右键单击故事板。2.Ctrl-从黑色窗口和ReferencingOutlet 拖动到情节提要上的查看。 在此处输入图片说明