I am going to have two targets in one XCode project.These two targets are basically very similar except one is a full version and another is a lite version.
They are supposed to use the same MainWindow.xib and ViewController.
The full version target is already there (I created and implemented at first). Now I wish to add the 2nd target, but I can't add the existing MainWindow.xib and ViewController from the first target folder.
How can I include the existing xibs to my 2nd target?
Thanks
There should be a info.plist for each target. Have you tried setting the second XIB as the main window for the second target?
Another suggestion is use the UIViewController's initWithNib message, where you can pass the correct nib to the View controller initialization routine based on the version of the program you want to make.
Related
This is my first application with multiple views.
I have an app that uses a storybord (main app), and another app with a single viewController and a nib file.
I would like to merge the singleView app as part of the main app.
Is there a way to do it?
How do I add the nib, and attach it to its viewController?
*Also please state if it's something that is really not recommended to do or not.
Please let me know if any more info needed.
You could simply copy whole view controller from the xib of the "single nib" project to a storyboard project.
Select "View Controller" in the xib of the single nib project as shown in image below and press cmd+c.
Open storyboard and press cmd+v. Your view controller from xib should be copied as shown in image below.
Now you should copy ViewController.m and ViewController.h (or whatever they are called) files from the single nib project.
Open Finder, find those files and drag them to the storyboard project in Xcode (somewhere in the project navigator). Be sure to select items shown in following image when copy dialog is prompted.
Now you should reconnect outlets and actions to copied view controller .h (cmd + drag from storyboard to .h file - you should already be familiar with this process)
And now you build to see if everything is working.
You should be able to just copy your existing single view nibs content into your story board. Just open both projects and copy-paste.
HOWEVER: I usually opt against storyboards. Especially when you're working in a team, they really mess things up (because of their single file/monolithic nature). I'd rather suggest you work on different files for each screen and tie them together with code.
While this may not be a concern for you, it may well be one later on.
I was trying to add a new view controller on Xcode 4.5.2, i made the xib file to be compatible to 5.1, started playing around with it and suddenly noticed that this custom table view cell is not getting loaded at all, it was always creating a crash on load.
[self.cellNib instantiateWithOwner:self options:nil];
I started checking the .app file which is getting created, i am able to see that except for this new custom table view cell nib files all the other xibs are in "nib" extension. what setting can make this xib file to be converted to nib like others.
Go to file inspector then select identity inspector as following:
In class select your particular class for that you want to add nib file.
You need to provide your custom class name in the field of Custom class 'Class' field.
All my view controllers and their xibs are in another project which is reference in the main project, the problem was with my methodology of reference to the main target. i was just pulling the xib file from the referenced project to the main target. the actual way of doing it is like this
touch the main target's xcodeprojfile, choose the target, build phases, in copy resource bundle press '+' and then add the xib file. Thanks to #vishal for his guess on the problem.
I'm creating an iPad version of an iPhone app (NOT universal). I created copies of all my .m .h and XIB files, and appended "iPad" to the end of each, as well as to all my classes. This of course was tedious and overly complex but I didn't know a better way.
My problem: When I connect the iPad File's Owner and First Responder to my iPad XIB (see image) Xcode connects the XIB shown below to the iPhone ViewController code and not the iPad ViewController code.
I then went to the code (see below) to see if I could instead connect straight from the code (with those little circles to the left of Outlet code lines) but to no avail. When I click and drag the line and let go over the XIB it doesn't work. It doesn't do anything.
How do I associate (for lack of a better word) my iPad XIB with my iPad code? The iPad XIB is already part of the target build, FWIW.
Click on FileOwner in iPad xib file..
Go to identity inspector..in the Utilities Section.
You will see the class name there..Make sure it points to the iPad code class
Make sure that you've included the correct File name in your XIB in the File Inspector. This should match the class you are trying to connect objects.
Check the class you given for each xib is correct .that is in the identity inspector
Try this
File->Reload All Class Files
File->Read Class Files (select MyClass.h)
Reconnect File's Owner by
a. Setting the Class to "MyClass"
b. Reconnecting the View to the File's Owner's View
Everything is back to normal now. Weird.
Hope this helps more than it confuses ;-)
In iOS 5 sdk with Xcode4.2 i started creating an app with Empty Application Template.But in that template there is no MainWindow.xib.Some posts says to add a MainWindow manually.Is that the right way or proceeed the same without MainWindow.xib for a navigation Based application
The empty application template does not contain any other files - it's an empty template! If you want to create a navigation based application, you can do it in code by creating a navigation controller and setting it as the root view controller of the application window, or you can create your own xib file and set it to the "Main Interface" in your target summary settings.
For information, in XCode4.2/iOS5.0, Apple added the concept of story boards. Now by default, no MainWindow.xib file is created but MainStoryboard.storyboard. You can use it to develop your application. BUT, for backward compatibility, prefer add a nib file that you can name MainWindow.xib. I do not know any other way to use NIB files as it was done before XCode4.2
I have a navigation based iPhone app, and I want to load a view (MainMenu.xib) when the app is launched, instead of MainWindow.xib. If I change the target's "Main Interface", the app crashes when it is launched. How do I fix this?
You have to add the view you want to display on MainWindow.xib......in the IB of MainWindow.xib you have to change the name of the class as well as the nib name (give the name of the class)
After doing this make the object of the view in the Application delegate
In navigation based you also need to give the name of the class you want to display(this class is the class in which you had designed your table view)
adding this comment a few years after the problem first posted as can cause problems if you have Storyboards to manually change MAIN INTERFACE instead of choosing from drop down. If value in field is not a .storyboard file then xocde changes the plist setting to NIB based project and breaks the whole project.
See my comment here
What does "Main Interface" in Xcode actually *do*?