开发者

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

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, bu开发者_Go百科t apparently that is not the case.

How can I manually bind the two?


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


Here it is in 5.1:

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

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


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..."


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.


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.


If you are looking an answer for the same problema in Xcode 12.1, just set the class for the view, and restart Xcode, it will do the trick.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜