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
Related
I am trying to upgrade my existing iPhone app project to an Universal app,
I have implemented following steps,
Step 1: Project Navigator - target - Summary - devices - Universal (From iPhone to Universal)
Step 2: Created TabBar with NavigationBar Flow in Storyboard,
When i run my project in iPhone it works properly but when i run in iPad it shows only TabBar with NavigationBar.
Now my problem is how to create new .xib files for iPad ? Xocde doesn't created automatically when i selected my device from iPhone to Universal.
or
How to map my iPhone .xib files with iPad.
Do i need to create new Outlet and action for all buttons which are there in my iPhone .xib?
Thanks in advance.
Create a new xib for all your view controllers ,name the view controllers with "~ipad " as a suffix(ex. FirstViewController~ipad.xib)
xcode will automatically use the xib when the application run in ipad. Link your newly created xib with appropriate classes through identity inspector in xib.
Note : After creating a new xib, add all the controls as added in existing view controller and link newly added controls with file owner.
add all the controls and link with file owner.
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 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*?
I'm reading through a beginners iPhone text book and just finished writing all the code for a route tracker app that uses Map Kit and Core Location. I have the app running with no errors on my iphone 4 device but when I tried interacting I realized that none of my IBOutlets were connected to anything. When I referenced the beginning of the tutorial in the text, all it says is to "connect the appropriate outlets".
Here's why this usually simple task has me confused. The tutorial says to create a Window Based Project, so there is no ViewController. Then, in Interface Builder, the view is built in MainWindow.xib. The only IBOutlets of the project are located in Controller.h / Controller.m files that you create and which contain mostly all of the code for the app.
I usually ctrl-drag from File's Owner to the UI in Interface Builder, but in this project there seems to be no way for me to access the IBOutlets in Controller.h / .m from the MainWindow.xib file.
I'm frustrated because it seems like this should be such an easy fix but I'm totally stumped.. any help is really appreciated. Thanks
As I see it, you have two choices:
Add the outlets to the app delegate. This is probably not the best plan.
Put an instance of your controller class in the .xib file.
I think option 2 is what you want. If you check the Controllers section of the library, you'll see a component called "Object". Drag one of those into your xib, then inspect it. Select the info pane in the inspector (the circle with a white i in it) and change the Class to the name of your controller class.
i have a tabbar controller created by interface builder. It has 5 tab with 5 views.
Now i can porting this project in ipad compatible version.
Using xcode and IB i created the correct views for ipad with "create ipad version using autosizing masks".
I have TestView_iPad.xib and TestView.xib
Ok!
Now, how can i load at startup in my tabbar controller the iphone or ipad correct nib file??? What is the right way?
I need to do this in my testview controller or in my appdelegate?
I recognize the devices correctly, but i not able to load from different nib file, because it where setted from interface builder (Nib Name = "TestView" from Inspector)!
someone have a trick?
thanks,
A
For my iOS app, I use two different NIBs and yes, they both have UITabBarControllers. The way I do it is by adding a key to my Info.plist: Main nib file base name (iPad) and copy the iPhone xib and rename it (Example: TabBar_iPad.xib) Then add your new xib's name as the value for Main nib file base name (iPad) and enter the xib's name destined for the iphone under the key Main nib file base name (iPhone)
It works great!