Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storyboard relationship in iOS

I'm attempting to use the new Storyboard feature, however I am confused about Storyboard Relationships? How are they different to IBOutlets?

Also how can I add my own relationship, to my own UIViewController subclass?

I have tried looking in the documentation but can't find much about them.

like image 237
Jonathan. Avatar asked Nov 13 '11 20:11

Jonathan.


People also ask

What is iOS storyboard?

The storyboard is first introduced in iOS 5 to save time building user interfaces for the iOS applications. It is a visual representation of the user interface of an iOS app. It can be defined as the sequence of screens, each of which represents the ViewController and the Views.


1 Answers

The way I understand it is: relationships are iOS's way of representing a 'parent-child' relationship and while that does seem quite recursive, an example of parent-child relationship is a UIViewController Container containing a UIViewController.

That's the theory anyway -- it's better understood using the UINavigationController. It is called a 'container' because it contains as many regular UIViewControllers in a 'stack' metaphor so you can do your normal UITableView drill downs and pop offs.

The key point is that the segue between UINavigationController and the first UIViewController in your stack, there is a 'relationship' while the segue between all the rest of the UIViewControllers is just a regular push segue.

The same thing is evident in the UISplitViewController -- it needs two view controllers (sometimes called content view controllers) from launch and these are connected up between the parent UISplitViewController (the container) and two regular (content) view controllers

(thus relationships are not like IBOutlets, but more like segues -- they are even in the 'segues' category of the standard view controller containers)

Now - we aren't allowed to subclass the standard view controller containers, but we are allowed to create custom view controller containers, but I can't for the life of me define a relationship in my custom view controller container!!!!!!!!!!!

so: "can I use them in my own controllers?" the answer is yet unknown (to me at least, and the documentation is thin at best)

like image 59
lol Avatar answered Oct 20 '22 00:10

lol