Storyboards

This is a great new feature in iOS 5.

New way of working using graphical interface in combination with new instance methods.

Matthijs Hollemans published a useful tutorial regarding storyboards.

A part that I found very useful is when he describes the mechanism of binding the source and the destination scene, read

Here’s a handy checklist for setting up the connections between two scenes:
1. Create a segue from a button or other control on the source scene to the destination scene. (If you’re presenting the new screen modally, then often the destination will be a Navigation Controller.)
2. Give the segue a unique Identifier. (It only has to be unique in the source scene; different scenes can use the same identifier.)
3. Create a delegate protocol for the destination scene.
4. Call the delegate methods from the Cancel and Done buttons, and at any other point your destination scene needs to communicate with the source scene.
5. Make the source scene implement the delegate protocol. It should dismiss the destination view controller when Cancel or Done is pressed.
6. Implement prepareForSegue in the source view controller and do destination.delegate = self;.

Let’s see some new methods of iOS5:

dismissViewControllerAnimated:completion:
Dismisses the view controller that was presented by the receiver.
– (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
Parameters
flag
Pass YES to animate the transition.
completion
A block that is called after the view controller has been dismissed.

So we dismiss the destination view controller from the source controller when we are implementing the delegate methods. In addition we can execute code after the screen has been dismissed using block.

You could have used dismissModalViewControllerAnimated: but I prefer the above!

Leave a Reply

Your email address will not be published. Required fields are marked *