Post on 01-Dec-2015
description
transcript
These are confidential sessions—please refrain from streaming, blogging, or taking pictures
Session 407
Adopting Storyboards in Your App
Joshua PenningtonInterface Builder
Intro to Storyboards Mixing Storyboardswith code/XIBs
New in iOS 6
Intro to Storyboards Mixing Storyboardswith code/XIBs
New in iOS 6
Passing Data
Passing Data
-prepareForSegue:sender:
Passing Data
-prepareForSegue:sender:
Passing Data
-prepareForSegue:sender:
DemoStoryboards
RecapStoryboards
• Two main concepts: Scenes and Segues-prepareForSegue:sender:
Intro to Storyboards Mixing Storyboardswith code/XIBs
New in iOS 6
Intro to Storyboards Mixing Storyboardswith code/XIBs
New in iOS 6
Mixing Storyboards with code/XIBsAdopting Storyboards in Your App
Tony RicciardiInterface Builder
Storyboards and Code
• Integrating with code-based views• Customizing transitions
UIStoryboard.hStoryboards and Code
+storyboardWithName:bundle:
■ Returns a new instance of UIStoryboard-instantiateInitialViewController
■ Returns a copy of the storyboard's initial view controller
DemoIntegrating Storyboards with code-based views
-performSegueWithIdentifier:sender:
UIViewController
-instantiateViewControllerWithIdentifier:
UIStoryboard
RecapStoryboards and Code
• Storyboards in code• Code-based views in Storyboards• Manual Segue triggers• Scenes without Segues
Intro to Storyboards Mixing Storyboardswith code/XIBs
New in iOS 6
Intro to Storyboards Mixing Storyboardswith code/XIBs
New in iOS 6
Embed SeguesNew Ways to Use Storyboards
Embed SeguesNew Ways to Use Storyboards
Foo
Content Area
Foo
How It Works Today
View Controller View Controller
How It Works Today
View Controller View Controller
@"ContentScene"
How It Works Today
View Controller View Controller
@"ContentScene"
UIViewController *child = [[self storyboard] instantiateViewControllerWithIdentifier:@"ContentScene"];[self addChildViewController:child];[[self view] addSubview:[child view]];[[child view] setFrame:frame];
How It Works Today
View ControllerView Controller
UIViewController *child = [[self storyboard] instantiateViewControllerWithIdentifier:@"ContentScene"];[self addChildViewController:child];[[self view] addSubview:[child view]];[[child view] setFrame:frame];
Embed Segues
View Controller View Controller
Embed Segues
View ControllerContent Area View Controller
Embed Segues
View ControllerContent AreaView Controller
Embed Segues
View ControllerContent AreaView Controller
There is no code.
DemoEmbed Segues
RecapEmbed Segues
• Add a container view• Create a segue from the container view to the destination scene• Use -prepareForSegue:sender: if needed
Unwind SeguesNew Ways to Use Storyboards
• Segues go to new instances only• Returning to previous controllers is a manual process
Unwind SeguesNew Ways to Use Storyboards
• Segues go to new instances only• Returning to previous controllers is a manual process
■ Define a delegate■ Use -prepareForSegue: to wire up the delegate■ Invoke the delegate■ Return any data; trigger navigation
Presenting ControllerDone
Reset
Billing ConfirmationName
... ...
Presenting ControllerDone
Reset
Billing ConfirmationName
... ...
Presenting ControllerDone
Reset
Billing ConfirmationName
... ...
Confirmation
Presenting Controller
Unwind SeguesNew Ways to Use Storyboards
Billing
...Done
Reset
Name
...
Confirmation
Presenting Controller
Unwind SeguesNew Ways to Use Storyboards
Billing
...Done
Reset
Name
...
Confirmation
Presenting Controller
Unwind SeguesNew Ways to Use Storyboards
Billing
...Done
Reset
Name
...
Picking the destinationUnwind Segues
• View controllers created in code/XIBs• Multiple paths back and forth
• Resolve destination at runtime- (IBAction)done:(UIStoryboardSegue *)segue {
// React to the impending segue // Pull state back, etc.
}
Picking the destinationUnwind Segues
• Resolve destination at runtime- (IBAction)done:(UIStoryboardSegue *)segue {
// React to the impending segue // Pull state back, etc.
}
Picking the destinationUnwind Segues
• Resolve destination at runtime- (IBAction)done:(UIStoryboardSegue *)segue {
// React to the impending segue // Pull state back, etc.
}
Picking the destinationUnwind Segues
Picking the destinationUnwind Segues
Confirmation
Done
Reset
-done:-reset:
Picking the destinationUnwind Segues
Confirmation
Done
Reset
Unwind Segue
Callback orderUnwind Segues
• Find the destination• Invoke -prepareForSegue:sender: on the source• Run the unwind action• Perform the segue
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
Runtime searchingUnwind Segues
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
Runtime searchingUnwind Segues
Runtime searchingUnwind Segues
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
-canPerformUnwindSegueAction:fromViewController:sender:
Unwind Segues
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
Unwind Segues
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
-viewControllerForUnwindSegueAction:fromViewController:withSender:
For custom containers
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
Runtime searchingUnwind Segues
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
Runtime searchingUnwind Segues
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
Runtime searchingUnwind Segues
-reset:
-segueForUnwindingToViewController:fromViewController:sender:
For custom containers
Runtime searchingUnwind Segues
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
-reset:
Runtime searchingUnwind Segues
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
-reset: -prepareForSegue:sender:
Runtime searchingUnwind Segues
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
-reset:
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
Runtime searchingUnwind Segues
Presenting Controller
ConfirmationBilling
...Done
Reset
Name
...
Runtime searchingUnwind Segues
-done:
DemoUnwind Segues
More Information
Michael JurewitzDeveloper Tools Evangelistjury@apple.com
Apple Developer Forumshttp://devforums.apple.com
Labs
Interface Builder Lab Developer Tools Lab CThursday 9:00AM
Intro to Storyboards Mixing Storyboardswith code/XIBs
New in iOS 6