XCode:IBOutlet 连接如何消失并仍然存在? [英] XCode: How can an IBOutlet connection disappear and still exist?

查看:18
本文介绍了XCode:IBOutlet 连接如何消失并仍然存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您右键单击它并打开黑色插座窗口时,插座引用连接如何在连接检查器中消失但仍然存在?

How can an outlet referencing connection disappear in the connections inspector but still be there when you right-click on it and that black outlet window opens?

我遇到了一个问题 Swift 3: Image 确实如此设置 isHidden=false 时不显示,其中当 isHidden 设置为 false 时,背景 UIImageView 从未出现.我发现连接检查器中不再存在引用连接的插座,但是当我右键单击视图控制器场景"->视图控制器"->视图"下的背景"一词时,打开了一个黑色的插座窗口连接就在那里!所以我删除了那个黑色窗口和 ViewController 中的连接,并控制将另一个 IBOutlet 从背景 UIImageView 拖动到 ViewController.

I had a problem Swift 3: Image does not show when setting isHidden=false in which a background UIImageView did never appear when isHidden was set to false. I found that the outlet referencing connection was not there anymore in the connection inspector, but when I right-clicked on the word "Background" under "View Controller Scene" -> "View Controller" -> "View" a black outlet window opened and the connection was there! So I deleted that connection in that black window and the ViewController and control-dragged another IBOutlet from the background UIImageView to the ViewController.

但是这怎么会发生呢?

推荐答案

但是这怎么会发生呢?

But how can that happen in the first place?

查看故事板文件中的实际 XML.对象通常有一个 部分,可能如下所示:

Look at the actual XML in a storyboard file. Objects typically have a <connections> section that might look like this:

<connections>
    <outlet property="nameLabel" destination="ABG-fa-Haa" id="dEC-Ro-Sac"/>
    <action selector="buttonAction:" destination="esT-2Y-Pvc" eventType="touchUpInside" id="aCT-ob-Q4d"/>
</connections>

这些是您在故事板编辑器中创建的连接.编辑器使用它从源代码中收集的信息来确定它应该让您创建哪些连接,但是一旦创建了它们,故事板和定义插座和动作的源代码之间就没有真正的连接.如果您随后更改或删除了这些定义,则在您删除它们之前,这些连接仍将在故事板中指定.

Those are the connections that you create in the storyboard editor. The editor uses information it gleans from the source code to determine which connections it should let you create, but once you create them there's no real connection between the storyboard and the source code that defines outlets and actions. If you subsequently change or remove those definitions, the connections will still be specified in the storyboard until you remove them.

这篇关于XCode:IBOutlet 连接如何消失并仍然存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆