I created a project in Xcode 6 beta 2, which initial had a storyboard. I wanted to work with separated xibs so I removed storyboard and line related to storyboard from Info.plist and added several xibs. Now the problem is that I can't connect file's owner 'view' outlet (because it's not visible) to view from xib. First thought was that I misspelled name of the file's owner custom class name (from Identity Inspector), but I didn't. Also file's owner class is a UIViewController child. I don't know that the problem can be. Did some faced this issue ?
It's probable that you need to close Xcode, clean the project and try again. I created a new project without storyboards and I did the following:
1) I created the nib file.
2) I created the UIViewController class.
3) I opened the nib and selected the File's owner tab. Then I wrote the name of the custom UIViewController class.
4) Without selecting the file's owner tab on the Placeholders left bar (make sure of this) go to Connections inspector tab and you should see the view outlet.
Simply cleaning, quitting Xcode and re-opening fixed it for me.
Related
The checkbox to create a .xib file in Xcode 6 seems to be disabled. I can not find any way to enable it again. Does anybody know if this is possible?
Make sure you didn't accidentally select the OS X Cocoa Class file type instead of iOS Cocoa Touch Class.
Incorrect:
Correct:
FYI, you can create xib file by follow.
Creating xib files in xcode 6 is,
First of all create empty project as,
Go to-> File > New >Project, Then select IOS >Other > Empty then Next
After that creating a xib file as,
Go to->File >New> File then IOS > Cocoa Touch Class and then NEXT
Then select Viewcontroller and check for the "Also create XIB file" Then Next
This will create a empty project as well as xib file.
I had encountered this problem. Below is fix for this :
Right click on files present in Project Navigator section.
Select New File.
OR
Select File from list of tab present in Xcode
Select New -> File
OR
Simply press cmd+N
Choose template for your new file as iOS not OS X, tvOS or watchOS.
Select Cocoa Touch Class and then press Next
Enter Class name and select subclass of it.
Checkmark Also create XIB file.
Select device type and Language and then click Next
Click on Create and make sure that Targets is selected.
This is a real 'WTF?' moment for me.
I copied some classes out from another project, including copy and pasting the code and some UIBulder components. What did NOT get copied was the XIB file (I went from XIB to storyboard).
My tab / swipe recognizers aren't activating, and when I drill down the only thing I can discover that can explain it is that somehow, someway, I'm hooking up against the XIB file. (When I click on the little button next to the IBAction/IBOutlet lines in the header, it shows me both the storyboard and the xib file as connected).
I'm not referencing that file anywhere that I can find, it's just somehow magically recognized in Xcode. I don't know what to do, how to fix this.
Anyone have any ideas?
Edit: The really annoying bit is that the file doesn't appear to be in my files list when I check there, I can't just delete the reference that way. And since it's referencing the file in the original project, I can't just delete it. (Any changes made in either project cause changes in BOTH projects; their both using the same xib file for some reason). I should be able to simply delete the reference to the xib file, but I can't find the reference.
If you copy the view controller code from one project into another project you will notice a strange thing happening with the outlet. It is referencing the view from the first project without you ever connecting any outlets.
If you left click the little circle and click the reference link you will even be taken to the storyboard view in the other project. Trying to figure out how to get rid of this reference can drive you crazy.
Well, the good news is that there is really nothing for you to fix. You didn't copy over some deep, hard to find referencing link. Xcode is just getting confused because the View Controller and the outlet name are the same in both projects. Basically just ignore what that little circle says. You can close the first project and Xcode will figure things out eventually. Right click your views in the storyboard to see what referencing outlets really exist in the current project. (See my fuller answer for more details.)
No need to delete Derived Data. That doesn't solve the problem anyway. Just try opening both projects at the same time again and you will get the same strange behavior.
The way I figured this out was to separately create two new projects that had view controllers with the same name and a referencing outlet with the same name. I never copied anything but Xcode showed one was referencing the other. Like I said, ignore the little circle.
I just had the same problem. What solved it for me was to close both projects, delete the derived data from both and then reopen the destination project.
I agree, it's a crazy problem.
I'm sure that this problem could happen and I fix it deleting the content of the Derived data folder of XCode.
I just want to add the steps of how to delete those files:
Don't Delete the DerivedData folder.
Go to preferences (Command ,) > Locations Tab
On Derived Data you are going to see the path, clic the right pointing arrow (that will open that location in Finder)
Close XCode
Select all the files inside the DerivedData Folder (do NOT select parent folder) and (Command Delete) or move them to the Trash and then Empty Trash
Open the project and you are done
I hope it helps someone
unless the xib file is in the project. it should not have a link to it.
the xib file connects to the .h file. not the other way around.
You may want to remove the connections in the storyboard and re-connect them.
Also make sure that the storyboard is the UI being started and that the item on the navigation stack is actually the storyboard page. But you should be able to connect both the storyboard and the xib file to the class at the same time. You just cannot connect one IBOutlet to more than one object in a single ui component (e.g. two buttons on the storyboard cannot both be connected to #property IBOutlet UIButton *myCurrentButton you must have a separate IBOutlet for each connection. On the other hand, any number of actions can be connected to an IBAction. which is why you get (id) sender on each action.
I dont know if this is exactly what you are experiencing, but I hope that understanding helps you debug your issue.
I have been working with Xcode 4.2.1, but following some tutorials and videos from the earlier version of Xcode.
As usual I had the problem with the Windows Based Application. I created a empty application for my Windows Based Application project and was following some steps from the same forum of how to add a MainWindow.xib file to my project using this post
There is no .xib file when I create a new "Empty Application" in XCode
I also followed one more post which has some good screenshots:
http://www.trappers.tk/site/2011/06/16/mainwindow-xib/
Now my problem is I cannot ctrl+drag of the window outlet from the App Delegate object to the Window object. The reason is I could not find out the window outlet from tze attributes menu. One can see the screenshot of how it is looking in my xcode:
And below one can see how it should have a windows outlet for the App Delegate.
Is there anything I am missing or left something behind before coming there. I followed the steps exactly as mentioned in the above posts. I tried creating new projects just to make sure Im doing everything correct.
Any information regarding this would be appreciated.
Thanks
Raaks
From your tutorial..
http://www.trappers.tk/site/2011/06/16/mainwindow-xib/
The answer to your problem is Simple(and also this is the way you should do most of the time in future..)
1) Click on File's Owner(In the placeholder section..left to the xib).
2) In the attributes section you will see a window Outlet..
3) Drag window from the attributes section(right click-drag or ctrl-drag.) and drop it on window in Objects window..(left to the xib)
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?
Go to the Identity Inspector (Cmd+Option+3) and change the class to myController.
Here it is in 5.1:
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.
I have the same problem with some xib files in different projects on different macs. IB is changing the Object IDs of some views in my xib file. I need only to double click the xib file from Xcode to open it in IB and then try to close the xib file again without changing anything and IB marks the xib file as dirty so that I have to save it again.
This drives me crazy because it will break all my localizations since they are depending on the object IDs (ibtool).
Any ideas or experiences?
Thanks
This was a bug in old versions of IB. They fixed it in, IIRC, 3.1.