XCode: How can an IBOutlet connection disappear and still exist?

浪子不回头ぞ 提交于 2019-12-12 01:37:14

问题


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?

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?


回答1:


But how can that happen in the first place?

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.



来源:https://stackoverflow.com/questions/39844581/xcode-how-can-an-iboutlet-connection-disappear-and-still-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!