Using Interface Builder and storyboards to build relationships between controllers - ios

Is there a way to use Interface Builder on a storyboard to establish relationships between controllers. e.g. similar to the way UITabBarController allows you to click-drag connections to other UIViewControllers in the storyboard to build up the viewControllers relationship?
i.e. when you click-drag from UITabBarController to another UIViewController a popup gives you the option to choose "Relationships - viewControllers". It then draws and maintains the line between the controllers on the storyboard. I want to be able to do the same thing for my own custom controllers.

I've tried, however it's looking bleak:
How to create custom view controller container using storyboard in iOS 5
is a start (see the source code posted in the comments) but it's a work around - you don't get the relationship segues, however you do get Custom UIViewController containment.
I just thought it'd be prettier... Maybe iOS 8 will include this

All evidence seems to point to the fact that this is not possible to do, at least in versions of XCode up to 4 and iOS versions up to 5. Will update if I discover this changes.

Related

Multiple developer work one storyboard in iOS

Multiple developers are working on one project using Git. However, multiple developers are not working at the same time on the same storyboard.
Currently we found out one solution :
Create a storyboard particular to a UIViewController like xib.
If this is not right way then suggest me which way is best?
Memory leak accord when i use multiple storyboard for separate VC?
It really depends on how complex your views/storyboards are.
You could have 1 storyboard, which has multiple UIViewControllers, and multiple folks can work on different view controllers, with low chance of conflicts. You could have one storyboard for each view controller, but IMO you don't have to. Our project sometimes have almost ten UIViewControllers in one storyboard, and things are fine.
My two cents here is that, use one storyboard to include multiple view controllers that are relevant in a same workflow (like Sunny said), and use xib for those small pieces that are repeatedly used in various places across the app. So for a complete app, you might end up with a few storyboards and each in turn has multiple related view controllers, plus some xibs if needed.
Split up the Storyboard into several Storyboards. You can extract subviews into container views. Then you extract these into their own storyboards -> Editor -> Refactor to Storyboard.

Storyboard and Programmatic design simultaneously

I use programmatic way to create design parts and I won't use storyboard for design. But at some design I feel it will be easy with storyboard, is it possible to do design in both storyboard and programmatic in one project simultaneously. If so please tell me the process.
You can. Everything you can do in the designer you can do in code (though not vice versa).
You can instantiate the storyboard using the "UIStoryboard FromName" methods. From the storyboard object you can then use "InstantiateInitialViewController" to get the initial view controller of the storyboard. From this point on the storyboard segues will perform as expected.
If you want to jump to a certain part of the storyboard, you simply use the other method on UIStoryboard which takes an Identifier.vc.
Once you are done with your storyboard view controllers you can then get rid of it programmatically as expected (use pop/dismiss depending on how it was presented).
It is similar to the technique used for splitting large storyboards into smaller ones. If you google "splitting large storyboards" you will be able to find a lot of articles which will help you.
Absolutely. Most (if not all) of the objects you see in storyboard are part of the UIKit, which you'll see is imported at the top of every View Controller Xcode makes for you. You can add UI Objects, like a UILabel, to a View using addSubview, for instance.
Technically, you don't need to use the Interface Builder at all (and there was a time when you couldn't), it just makes things incredibly faster to produce.

UIViewcontroller in UIViewController which exceeds the bounds

I have a UIViewController having two parts:
a UIView
a bar having multiple drop down menus arranged horizontally and having thumbnail images at the top
Because second part is little complex I've decided it to be a UIViewController but now I have some concerns:
Because I have drop down menu, menu will exceeds the bounds of the bar. How can I handle it?
Is it a good way to have a UIViewController inside a UIViewController?
How can I implement a drop down menu? As far I know IOS doesn't have drop down menus.
To use a controller within another controller, you employ a custom container view controller.
See Creating Custom Container View Controllers section of the View Controller Programming Guide for iOS.
Also see the appropriate Implementing a Container Controller section of the UIViewController Class Reference.
Also refer to the WWDC 2011 video, Implementing UIViewController Containment
In iOS 6, you can set up storyboards with container views that automatically employ embed segues, saving you from needing to explicitly call addChildViewController and the like, if you're using storyboards. Check out the "container view" object in Interface Builder. If you're going to be changing the child controller, you'll have to employ the API referred to in the above links, but for the configuration of the first child, you can set that up in Interface Builder in iOS 6.
In this case, setting up a controller containment could be the right way. The only limitation is that it works for iOS 5 and greater.
Here, what you have to do:
// add as child VC
[self addChildViewController:_barViewController];
// add it to container view, calls willMoveToParentViewController for us
[_containerView addSubview:_barViewController.view];
// notify it that move is done
[_barViewController didMoveToParentViewController:self];
Here, you can find additional info Containing ViewControllers. Obviosly Apple doc is your friend. In addition, if you search for "uiviewcontroller containment" you can find a lot of tuts out there.
If your app needs to target devices where iOS 5 is not the minimum, you should rely on a UIViewController and two different views.
About drop down menus, in my opinion they don't work so well with touch interfaces. There are some alternatives, for example an instance of the UISegmentedControl class. Here you can read Apple UI design guidelines about segmented controls: http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW1. If you explain a little bit more about your desired UI functionality we could offer you a better alternative from the user experience point of view.
If you insist with drop down menus, there are some third party control libraries available out there; for example: http://www.cocoacontrols.com/

Do I need multiple view controllers for the iPhone & iPad storyboards?

I'm still relatively unfamiliar with all the new features of iOS 5, and what I can do in Xcode now. So, a good explanation would be appreciated.
I'm designed a single-view application and I have both an iPhone and iPad storyboard. I chose 'Single View Application' when I first started, so Xcode created a ViewController for me. Both storyboards list this view controller as their own.
Back in iOS 4 the way that I linked button actions to my view controller was to Right-Click on the button on the nib, pick the action that I wanted, then drag it over into the view controller's '.h' file, which auto-created a method/property for me.
I am confused about how to accomplish this now, since I have multiple storyboards but only one view controller. Do I need to have multiple links for each button; one for the button on the iPhone and one for the iPad? Or is there a better way to accomplish what I am trying to do now?
You do it the same way you did it in iOS4. But obviously you never built an universal app there ;-)
It's totally okay to have a single UIViewController class for two different nib files.
And if you use storyboards it's fine to use different storyboards and a single viewController too.
You can even use the same viewController for different scenes inside a single storyboard.
The connections to the viewController are saved in the nib or storyboard. So you can't overwrite them while designing the other user interface.
Open the iPhone storyboard, make your connections to actions and outlets. Then open the iPad storyboard and make totally independent connections.
In response to the first reply, I was under the impression that a view controller could only support two scenes in a storyboard layout. I say that because I found this thread.

Using Storyboard how to interact with viewcontroller objects

I've reviewed many websites and youtube videos that have IOS 5 storyboarding information. Most of them are pretty basic and only describe how to get started with storyboarding and how to segue into other views. I'm interested in taking it a step further and actually adding custom code to the views contained within the storyboard.
Is the "normal" workflow when creating an IOS app using storyboard?
Create the layout of an app using storyboard (adding views and objects to those views).
Create viewcontroller files (.h and .m), one for each view contained within the storyboard.
Hook up the scenes from the storyboard with your own view controller subclasses by editing the "class" values in Identity Inspector.
I believe I followed those steps, but when I implemented step #3 above and ran my application, I was only able to see a black screen. The view I had created in storyboard wouldn't display.
You have the right steps. Make sure you create your .m and .h without a xib. Post your code for the view controller for your first view to get more help.
yes, this is the normal workflow. have you set the "initial viewcontroller? ?
see this image: http://dl.dropbox.com/u/31437518/Screen%20Shot%202012-01-24%20at%2012.29.34%20AM.png
It sounds like you made a storyboard file but it isn't being loaded.
Do you have the main storyboard setting in the target summary screen filled in?

Resources