Storyboard add viewcontroller's view into another viewcontroller iOS5+ - ios

Anyone know if it is possible to create your views in the storyboard which can be used for a main view?
I have tried instantiating my viewcontroller with the identifier and then adding the view from the viewcontroller, but the frame isn't the same as the frame I used in the storyboard.
I know it is possible to use the container view in the storyboard. But I cant use that in iOS 5.0.

Do not create viewcontroller in storyboard. Create a separate xib file then instantiate controller using xib and add the view as subview in main view.

Related

Have a UIContainerView point to a ViewController in another Storyboard?

I understand that UIContainerView can be used to embed a UIViewController inside another UIViewController in a Storyboard. However, I would like the embedded UIViewController to live in a different Storyboard file. Is this possible, and if so, how do I make the connection?
You can do that by following the these steps:
In the Storyboard that contains the view controller you want to segue to, set the Storyboard ID for that view controller.
In the storyboard containing the container view, drag a Storyboard Reference from the Object library.
From the attribute inspector, set the Storyboard that contains the view controller you want to segue to, and set the Referenced ID to the ID you set in step 1.
Connect the embed segue between your container view and the storyboard reference like if it is a view controller in the same storyboard.
That's all!

How to initialize UITableViewController inside a UISplitViewController?

I just dragged out a UISplitView from the storyboard and set the classes of the root and detail view controllers. I am wondering how to initialize my UITableViewController (as it needs some setup before it is read to be used). This might be easier if I create the UISplitView programmatically. Still, is there a way for me to set up my UITableViewController in the UISplitView? Thanks!
You can just drag and drop a UISplitView to your storyboard and create master view and detail view classes in your bundle. Then assign each class to each viewcontrollers in xib :

How to use a uittabbar controller with a xib?

So I'm trying to use a uitabbarcontroller. I use interface builder and drag it like usual.
I then try and drag another view controller onto this
But this leads to this-
So I can't see two view controllers.
So how do I actually use this with a xib?
Add UIViewController in Xib not on UITabController. Then link UIViewController to UITabController.

How to add UIViewController as target for a programmatically added subview like in IB

When adding UIViews in Xcode's interface builder you can use Ctrl+drag to create a target-action to the UIViewController that holds that view. You can also do that to any subviews you add using IB.
If a subview is created and added programmatically in awakeFromNib is there a way to add the target-action from it to the view controller right there or do you have to first create the subview in awakeFromNib and later create the target-action using the view controller as a delegate?
If its created from scratch, you have to bind events manually.
If however it's loaded from another NIB, there're at least 2 options:
You can get a uiviewcontroller from view, see this answer: https://stackoverflow.com/a/3732812/126995 Then you can pass the VC to the loadNibNamed:owner:options: method.
In the IB, you can change the type of the root view from UIView into your custom UIView-derived class, and bind actions and outlets from the subviews to the NIB's root view.

Using NIBs in UIStoryboard

For an ipad application in ioS5.0 using arc and storyboard, i wanted to create another custom view and instantiate several instances of that view within a scrollview so as to show a scrollable train of these custom views. To do this, I created the custom view in XIB file, however, how should I instantiate this view in the ViewController being refrenced within the storyboard. The custom view also has a gesture recogniser within it.
thank you in advance for your help on this.
I don't think there is a way to instantiate a nib backed view from a storyboard. You can do most of the layout in your storyboard, but then you will have to programmatically build your nib backed views and add them to the scroll view.
As a side note, it sounds like you are building something that could be solved with a UITableView and a prototype cell. Here is a pretty good tutorial.

Resources