How to create an iOS project with a XIB in XCode 5 - ios

I'm running xcode 5.0.1. In previous version Xcode, there was to be a checkbox for not using storyboard when creating a ios project. How do I turn off storyboards and just use xib files in xcode 5.0.1?

Unfortunately, the built-in project templates in Xcode 5 mandate storyboards, unless you pick the Empty Application template. Your choices therefore boil down to:
Start every project as an Empty Application and add your view controllers from the ground up
Start using one of the storyboard-based templates, then:
Delete the storyboard file
Change the main storyboard setting in your project to be empty
Add .xibs to the existing view controllers as needed
Implement your app delegate methods as needed to set up a view controller hierarchy

Open a new project as an empty project. The selection is in the bottom row, second from the right. Then you can add your view controllers in your app delegate. Hope this helps.

Related

Integrating one iOS project into another iOS project [duplicate]

This question already has answers here:
importing one Xcode project into another
(2 answers)
Closed 6 years ago.
I have one existing project. Now i have developed one project with some new feature. Need to integrate the existing project to this. When i run this project it shows this app functionalities. On that one button click to show the existing project home page and continue that existing project. I need to enter the existing project and use that functionalities and UI whatever and exit from that to continue the current project. Kindly give me solution. If you don't know requirement ping me i will explain with detail.
You can possibly add the project folder of your project to your existing project and then once you are in your existing project on the click of your button you can do this,
UIStoryboard *sb = [UIStoryboard stoaryboardWithName:#"Main" bundle:nil];
This will load the storyboard of your new project, if you have made the project using xib then you can load the xib as well
Then you can,
ViewController *firstController= [sb instantiateViewControllerWithIdentifier:#"firstController"];
This will load the view controller of your new project, then you can do this to present this view controller,
[self.viewController presentViewController:firstController animated:YES completion:nil];
This will load your view controller now you can do what you want in your new project.
To comeback to your existing project you can set your new project delegate to be your old project and implement methods to comeback.
Hope this helps.

how does LaunchScreen.storyboard redirect to Main.storyboard

I'm newbie of iOS developer, and I know that is very simple question but I really can't understand reason.
when I build SingleViewApplication, Xcode auto generate LaunchScreen.storyboard and Main.storyboard,
but I can't find any code like [self.navigationController pushViewController:] which may choose that what view controller enter stack as last one of top-level view,
I only find ViewController.{h,m} as first and see no logic that change view from LaunchScreen.storyboard to Main.storyboard.
could anyone help? thanks..
Main.storyboard file and LaunchScreen is define in your project property.
you can find it by click on project in xcode and then in below target you can find this two name you can choose your own by selecting dropdown given beside label.
and other redirecting to LaunchScreen to Main.storyboard you can refer info.plist file in your project and also AppDelegate.h and AppDelegate.m
Most probably the iOS first looks for LaunchScreen.storyboard file and shows it for some time and when it is done with it, it looks for Main.storyboard.
These names are hardwired in the plist as mentioned by Tejas in his answer and you can change these.
I don't think the the LaunchScreen.storyboard is pushing the Main.storyboard. Everything is managed behind the scenes and you can't change this behavior.
What you can change is the initial View Controller in your Main.storyboard so that it is instantiated immediately after the LaunchScreen.storyboard disappears and the app is fully loaded.

Storyboards in Xcode 6

I have recently started to learn iOS with obj-c from "iOS Programming The Big Nerd Ranch Guide 4th Edition". This edition was released in 2014 and is written with Xcode 5.
I am trying to make a simple app with two buttons and two labels. The labels are connected to two arrays and when a button is pressed an object from the corresponding array is shown in the corresponding text label (it's the Quiz app in chapter 1).
I created the project as a Single View app in Xcode 6, and put all my objects in the view controller class. I have two labels two buttons two arrays and an int to keep track of the object that has to be displayed from the array.
In the book it says that I should initialize the arrays in the initWithNibName method. I tried that but for some reason it never gets called. So I changed the initialization of the arrays to the init method. They initialize fine but when they are called from another method they are nil. Do you have any idea why this is happening?
The second issue I'm having is that I can't manage to get the contents of the storyboard on screen. It says that I'm supposed to make an instance of the ViewController inside the AppDelegate and make it the root window controller but all I get is a white window (or black in case I don't set the color).
UPDATE: I changed the intialization of the arrays from the init method to the viewDidLoad method and now they seem to be working fine. Nothing on the screen though.
It sounds like you're initializing your UIViewController from the app delegate AND a storyboard. If you create a new project in XCode, a "Single view application", you won't have to touch the app delegate at all in order to get something on the screen.
I believe both your problems are related to this, since it sounds like you're seeing an empty UIViewController on the screen (the one you create in the app delegate)
As for the initialization of your array, viewDidLoad is a popular place to do this.
If you are using storyboards, the method initWithNibNameOrNil will not be called. In the BNR book, it teaches you to use XIB files, which do use this method. If you are trying to follow the tutorials, I would suggest using XIB files.
For use of a book, I would suggest downloading whatever version of Xcode is being used for that book -- otherwise you will be running into a lot of confusing problems while learning.
If you would like to download previous version of Xcode, refer to this post:
How to download Xcode DMG or XIP file?

framework with view controller and storyboard

Is it possible to create a cocoa touch framework in swift which contain storyboard and viewControllers?
If yes can you give me a reference to a guide or something to get started? all the examples i see of creating frameworks are very simple classes which don't involve ui
I want to create a framework which involve UI
Yes, that is possible.
All you have to do is to create a cocoa framework as you normally do from File > New > iOS - Cocoa Framework..
Since this involves UI, Click on the project and right click > New > iOS - Storyboard. And after that it is just as simple as you do it in a normal app. Once your stuff is over in the framework side, you gotta create a new project to test your framework with UI (make sure that the class created in fw is a public class ).
To load the storyboard of your framework instead of your sample project's storyboard, do the full in ViewWillAppear method.
Create an object for storyboard along with the bundle (of your framework - normally it will be your VC's name)
instantiateInitialViewController
And present them
And you'll have your framework's storyboard in your sample project.

Storyboard crashes Xcode when opened

Whenever I attempt to open up my storyboard, Xcode crashes with the following error report
The funny thing is, the app works fine in the simulator and builds without errors. What is causing this crash? I see two possible crashes:
Exception reason: UITableView dataSource is not set
, but that shouldn't make the storyboard crash right?
Details: Failed to compute auto layout status IBLayoutConstraint, IBUIButton, IBUIDatePicker, IBUITextField, IBUIView, IBUIViewController, and IBUIViewControllerAutolayoutGuide.
Which doesn't give much information at all.
I have been using a storyboard with Xcode 5 for some time, so the question does not appear to be related to moving from Xcode 4 to 5. I can open the storyboard as XML and I can open my iPhone storyboard just fine.
If you are using git, I would recommend reverting to a time before this problem started.
If you are not using git, and you are absolutely sure you did not edit the xml for the storyboard then I would say:
1)find the storyboard file using the finder.
2)copy it to your desktop.
3)go back to Xcode and delete the storyboard from your project, select "move to trash". 4)re-import the storyboard file into your project.
Ive had similar problems with Xcode 5 and either reverting using git or the steps above usually get me back up and running.
Exception reason: UITableView dataSource is not set
Details: Failed to compute auto layout status IBLayoutConstraint, IBUIButton, IBUIDatePicker, IBUITextField, IBUIView, IBUIViewController, and IBUIViewControllerAutolayoutGuide.
The errors described above lead me to think that one if not all viewcontroller(s) for the items listed above lost their connectivity to viewcontroller.h / viewcontroller.m files. I would make sure you have everything wired up correctly, and you can check this by making sure the items in your viewcontroller have a circle in the gutter (next to the line numbers) that is filled in (solid) if the circle is not filled in then it means your items are not wired up to your viewcontroller. I would post a picture of your .h / .m file of your viewcontroller so we can further investigate.
I ended up copying each view controller scene (in XML) into a new storyboard. Some view controllers could not be copied without the storyboard crashing so I had to recreate about 4 of them, but by and large I got the majority of my work back.
What you need to do is reopen the project again in Xcode 5 and then go to the storyboard. Then at the right side choose for "Identity and type" and then set "opens in" to Xcode 4.6 to be able to open it in Xcode 4.6. And disable auto layout, somehow when you open it in xcode 5 it asks you to update it, I think you did that without a thought, happened to me as well :)

Resources