Have a UIContainerView point to a ViewController in another Storyboard? - ios

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!

Related

Embedding TableView in TableViewController into another view

I would like to customize content of table view controller(add some buttons, etc.) but root view for that is table view. Is it a way to embed it into another view and add controls on it?
You can use Container View.
In the storyboard create another view controller that you would use to host those controls. Then drag in Container View from the Object Library (normally the last item in the list) and place it where you want the table view to appear (which could be the whole screen). Doing this, the Container View will create another view controller. Simply delete that and ctrl drag from the Container View to your table view controller and select embed segue.
By doing this, you would not have to change anything in your current table view controller if it doesn't depend on other view controllers to give it data in order for it to work. If it does, however, you could assign the segue identifier to the embed segue, implement prepareForSegue:sender: and do whatever you would normally do with other segues.
You simply add TableView as a subview of a uiviewcontroller. Remember to call for delegates. Normally i don't use storyboards, but if you do it programmatically you can do like this:
On .h file:
#interface EmbeddedTableView : UIViewController <UITableViewDelegate, UITableViewDataSource>
And on .m file simply create your tableView by adding it as subview of viewcontroller.
You can look at this for example: How to set up UITableView within a UIViewController created on a .xib file

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.

Is it possible to use UIStoryBoard in a different UIStoryBoard's UIViewController?

I want to divide my flows in a separate storyboards.
At this point, i have created my main storyboard which is side menu.
What i want to do is, when a menu item is pressed i want to be loaded from another storyboard inside the main view controller view.
Is it possible, if yes,
How to achieve this goal?
To initiate a view controller from a storyboard named #"myStoryboard", and if you are using Restoration ID to create your controllers, you can do :
[[UIStoryboard storyboardWithName:#"myStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:#"ControllerID"];
(of course, #"ControllerID" refers to the ID you've set for your controller in the storyboard)
You can use a storyboard for any part of a program. Storyboards are not an all or nothing concept. You can have just one view controller in a storyboard, or a small network that just represents a subsection of your app.
To use just one view controller from a storyboard:
Add a new storyboard to your existing project.
Add a single view controller to the storyboard.
Assign an identifier to the view controller in the inspector.
Use the UIStoryboard class to load the storyboard resource
Use -[UIStoryboard instantiateViewControllerWithIdentifier:] to create a new instance of that view controller.
Install the view controller some place in your app by doing something like pushing it on to a navigation controller, or run it modally.
Author:Jon Hess

Storyboard add viewcontroller's view into another viewcontroller iOS5+

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.

Resources