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

2019-03-09 16:24发布

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.

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

How can I manually bind the two?

5条回答
等我变得足够好
2楼-- · 2019-03-09 17:01

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.

查看更多
smile是对你的礼貌
3楼-- · 2019-03-09 17:07

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

查看更多
做自己的国王
4楼-- · 2019-03-09 17:11

Here it is in 5.1:

enter image description here

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

查看更多
ら.Afraid
5楼-- · 2019-03-09 17:13

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.

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

查看更多
forever°为你锁心
6楼-- · 2019-03-09 17:13

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

you will find this line there...

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

Change the MyClassName to 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.

查看更多
登录 后发表回答