Connect multiple view controllers from storyboard to code in Xcode 6 - ios

I created multiple view controllers on storyboard. Now I wanna create several view controller .m and .h files to represent these view controllers respectively. How do I connect the file to its correspondent view controllers? For instance, there are 2 view controllers created and I wanna connect FirstViewController.m file to the first view controllers and connect SecondViewController.m file to the second one.

Select the controller, go to the identity inspector, and change the class from UIViewController to your custom class, which should show up in the pull down menu..

ViewControllers on storyboard can have the same class and you can have different models for each.
now it depends on your needs :
Panel Utility (on left)
identity inspector (3rd from left to right)
chose your class or let the default one if you don't need

Related

(Xcode 7.3.1) Not able to connect subview controllers to view controller.swift

I am trying to make a card game with multiple view controllers. I have created my application in a single view application, and have been trying to use multiple view controllers. When attempting to drag the images/buttons into the view controller code, it will not accept it unless it comes from the main view controller. I have posted screenshots that show my problem
You have to make separate class for for every view controller and you have to assign that class to respective view controller from identity inspector from utilities.
Check the screenshot,
So here setting view controller is class , subclass of viewcontroller. So, create subclass of viewcontroller, then select respective viewcontroller from interface builder and assign that class to that view controller and then open that class in assistant editor and you will be able to connect outlets or ibactions.

how to work with multiple viewcontroll and use the viewcontroll.h and m file

I am new with xcode.
I used one viewcontroller and coded it in the viewcontriller.h and .m files.
My problem is when I add more viewcontrollers, I can't create more action from the new viewcontrollers to the basic files (viewcontroller.h and .m).
For example to right click and drag swipe recognizer from new viewcontrollers to the viewcontroller files (h&m files) in interface builder.
As my comment seems to be the answer, I'll add it as an answer:
I suspect you do want to set the class of the newly added view controllers in interface builder to the class of the view controller you want it to be.
Then, you can drag-connect like with the first one, xcode did set up for you initially.
Also, do remember to use different view controllers for different purposes (you might have to create another subclass of UIViewController).

Can't use the drag function in .h when using storyboard with more than one view controller

I can't use the control drag function to hook up a button to action in .h when using storyboard with more than one view controller
Please help me...
Are you sure you've assigned the view controller a custom class? and dragging to that specific class? Each view controller should have its own Obj-c class. To create one:
press cmd + n and create a new Objective-C class and make it a subclass of UITableViewController (or the view controller you used in your Storyboard). after doing so, go to you Storyboard and select the view controller, on the right menu choose "Identity Inspector" and set the custom class name to the name of the class you just created.
Set the class file name for the UIViewController of the storyboard file at the identity inspector .

Cant add new xib's to view controller

I am working on one view controller which has three static screens which i m going to show to user for first time when he installs the app, for next time forever i will show him main functional view.
Problem is
When i have created viewController class i never selected xib option.
Now i have added two xib's (iPhone and iPad) in project.First i deleted the present view from it then I have created three static views in each which contains some label and one button in each..
I want to add those views in my view controller's view. and i want to add targets for buttons in those view.
I am unable to reference outlets in my class for all three views
and can't add target for buttons in my viewController.
How can i do that??
Please help......
Solved it..:)
Problem was when i have added new xib file to project.i deleted the present view controller view from xib...thats why xib was unable to find any of the projects view controllers in custom class drop down
When you click on the File's owner on the left while the XIB is opened:
Select the the third icon on the far right, and make sure the correct class is selected under Custom class, the green textfield:
You need to select File Owner then go to the identity inspector in right pan of Xcode where you can select yor Xib name :)

how do i generate view controller code defined in a storyboard

Here's what i'm doing :
I'm creating an xcode project using storyboards, defining all my screens by drag'n'dropping view controllers and views, but then I need to actually fill those screens with something.
So, i create uiviewcontroller subclasses files in my project, and fill the class name for every view controller in my storyboard. Then, I need to manually drag'n'drop every view elements into my view controller one by one, to generate properties.
I was wondering whether xcode offered the possibility to simply generate all the uiviewcontroller subclasses directly from the storyboard with all the outlets properties already set.
No.You only have to mention outlets and actions for all components which you want to use.If its automatically creates all outlets and properties and you cannot use "code conventions" for your application as you like.Sometimes your labels titles are static and you dont need outlets.so you have to connect each and every component.
http://oleb.net/blog/2011/06/creating-outlets-and-actions-via-drag-and-drop-in-xcode-4/

Resources