Xcode 4 Interface Builder:如何设置文件的所有者

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

Xcode 4 Interface Builder: How to set File's Owner

xcodeinterface-builder

提问by Haoest

I have myController.h and myController.m defined, and proceeded to create a myController.xib with the Wizard. I can't, however, connect the controls from the xib file to the class interface. Usually when I drop the connection cross hair on the File's Owner icon, it'll show me a list of properties that have been declared as IBOutlet, but this time it's just nothing.

我定义了 myController.h 和 myController.m,然后继续使用向导创建一个 myController.xib。但是,我无法将 xib 文件中的控件连接到类接口。通常,当我将连接十字线放在 File's Owner 图标上时,它会向我显示已声明为 IBOutlet 的属性列表,但这次什么都没有。

I thought the names of the class files and XIB file (myController) automatically binds File's Owner, but apparently that is not the case.

我认为类文件和 XIB 文件(myController)的名称会自动绑定文件的所有者,但显然情况并非如此。

How can I manually bind the two?

如何手动绑定两者?

回答by Deepak Danduprolu

Go to the Identity Inspector(Cmd+Option+3) and change the class to myController.

转到Identity Inspector(Cmd+Option+3) 并将类更改为myController.

回答by Patrice Gagnon

Here it is in 5.1:

这是 5.1:

enter image description here

在此处输入图片说明

I thought I would add this screenshot as it took me some time to find it!

我想我会添加这个截图,因为我花了一些时间才找到它!

回答by jeet.chanchawat

I found a way to do it manually... When the world is not using XIB(s) anymore... Open the XIB or NIB file in your favourite text editor

我找到了一种手动完成的方法...当世界不再使用 XIB 时...在您喜欢的文本编辑器中打开 XIB 或 NIB 文件

you will find this line there...

你会在那里找到这条线...

        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MyClassName">

Change the MyClassNameto the class you want to refer it to, save the file and your file's owner will be changed. Caution: Close Xcode (To auto reload the changes) and also take a backup in case you mess up something.

将 更改为MyClassName您想要引用的类,保存文件,您的文件所有者将被更改。注意:关闭 Xcode(自动重新加载更改)并备份以防万一。

回答by guitar_freak

Had the same question... XCode 4.2 enables to create a subclass of UIViewController and there you can optionally check the "with XIB for user interface" option.

有同样的问题... XCode 4.2 可以创建 UIViewController 的子类,您可以选择选中“使用 XIB 用于用户界面”选项。

New File... >> UIViewControler subclass >> "with xib..."

新文件... >> UIViewControler 子类 >> "with xib..."

回答by Tom

I've experienced the same issue while in Xcode 4: while trying to make a connection to file's owner, the icon did not respond while dragging the connection line and hovering over file's owner. Resetting the custom class didn't work. I ended up trying quitting and restarting Xcode and only this did the trick.

我在 Xcode 4 中遇到了同样的问题:在尝试与文件所有者建立连接时,图标在拖动连接线并将鼠标悬停在文件所有者上时没有响应。重置自定义类不起作用。我最终尝试退出并重新启动 Xcode,只有这样才能成功。