xcode 连接文件所有者以查看问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8438153/
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-14 22:42:52  来源:igfitidea点击:

Connecting File's Owner to View Issue

xcode

提问by Henry F

I'm having an issue connecting the view and IBActions/Outlets to File's Owner in Xcode 4.2's nib. When I create a new nib file, I'm going to File -> New File -> Select UI on the right -> Select "View" -> Device Family of iPhone -> then save it as TestView.xib. The new nib appears, but when I try to control + drag from File's Owner to View or anything else, nothing at all happens, the line just disappears without letting me select it as an outlet. The same issue occurs when I try to connect IBActions, Pickers, Labels or really anything to File's Owner. I cannot connect anything to it.

我在将视图和 IBActions/Outlets 连接到 Xcode 4.2 笔尖中的文件所有者时遇到问题。当我创建一个新的 nib 文件时,我将去 File -> New File -> 选择右侧的 UI -> 选择“View” -> Device Family of iPhone -> 然后将其保存为 TestView.xib。新的笔尖出现了,但是当我尝试控制+从文件所有者拖动到视图或其他任何东西时,什么也没有发生,这条线就消失了,没有让我选择它作为出口。当我尝试将 IBActions、Pickers、Labels 或其他任何东西连接到 File's Owner 时,也会出现同样的问题。我无法连接任何东西。

I'm working through a programming book that provided source codes, and when I play around with the nibs in there, everything is already connected to File's Owner. I can reconnect everything just fine in those files as well. I've been having to type up the program and then drag and drop the source codes nibs rather than being able to do it myself.

我正在阅读一本提供源代码的编程书,当我在那里玩弄笔尖时,一切都已经连接到文件所有者。我也可以重新连接这些文件中的所有内容。我一直不得不输入程序,然后拖放源代码笔尖,而不是能够自己完成。

I'm sure that there is something little that I'm missing, and I've been doing research on it and trying to figure it out for days to no avail. Any help would be much appreciated, thank you!

我确信我遗漏了一些小东西,我一直在研究它并试图弄清楚几天无济于事。任何帮助将不胜感激,谢谢!

回答by jrtc27

My guess is that you have not set the class for File's Owner correctly. Select File's Owner in the vertical bar on the left of the Interface Builder view, and in the Utilities (right) bar, go to the third tab (Identity inspector) and set Class to be your view controller's class.

我的猜测是您没有正确设置 File's Owner 的类。在 Interface Builder 视图左侧的垂直栏中选择 File's Owner,然后在 Utilities(右侧)栏中,转到第三个选项卡(身份检查器)并将 Class 设置为您的视图控制器的类。