Getting Started with Multitasking on iPad in iOS 9 · Multitasking Sessions Getting Started with Multitasking on iPad in iOS 9 Presidio Tuesday 4:30PM Multitasking Essentials for
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
override func willTransitionToTraitCollection( newCollection: UITraitCollection, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { super.willTransitionToTraitCollection(newCollection, withTransitionCoordinator:coordinator) switch newCollection.horizontalSizeClass { case .Compact: // Change your UI for a compact width case .Regular: // Change your UI for a regular width case .Unspecified: break // Do nothing } }
Strategies4: Adaptivity callbacks
override func willTransitionToTraitCollection( newCollection: UITraitCollection, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { super.willTransitionToTraitCollection(newCollection, withTransitionCoordinator:coordinator) switch newCollection.horizontalSizeClass { case .Compact: // Change your UI for a compact width case .Regular: // Change your UI for a regular width case .Unspecified: break // Do nothing } }
let animation = { (context: UIViewControllerTransitionCoordinatorContext) -> Void in // Change your UI here. It will animate from the old to the new. }
let animation = { (context: UIViewControllerTransitionCoordinatorContext) -> Void in // Change your UI here. It will animate from the old to the new. }
let animation = { (context: UIViewControllerTransitionCoordinatorContext) -> Void in // Change your UI here. It will animate from the old to the new. } coordinator.animateAlongsideTransition(animation, completion: nil) }
let animation = { (context: UIViewControllerTransitionCoordinatorContext) -> Void in // Change your UI here. It will animate from the old to the new. } coordinator.animateAlongsideTransition(animation, completion: nil) }
Be flexibleAuto LayoutSize Classes in XcodeAdaptivity CallbacksHigh-level APISplit View Controller
Strategies
AdaptivePhotos
Sample code
MultitaskingAdapting to dynamic size changes
StrategiesGuidelines
GuidelinesThe user controls your app’s size
GuidelinesThe user controls your app’s size
The app cannot prevent size changes
GuidelinesThe user controls your app’s size
The app cannot prevent size changesIt cannot cause size changes either
GuidelinesThe user controls your app’s size
The app cannot prevent size changesIt cannot cause size changes eitherSize changes can happen at any time
GuidelinesKeep the user oriented
GuidelinesKeep the user oriented
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read☐ Write
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read
Regular Width
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read☐ Write
Regular Width
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read☐ Write
Compact Width
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read☐ Write
Compact Width
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read☐ Write
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read☐ Write
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read☐ Write
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read☐ Write
✅
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
School☐ Read☐ Write
✅
GuidelinesKeep the user oriented
GuidelinesKeep the user oriented
Don’t make abrupt jumps
GuidelinesKeep the user oriented
Don’t make abrupt jumpsBe smart in new ways
GuidelinesKeep the user oriented
Don’t make abrupt jumpsBe smart in new waysEspecially going from large to small
GuidelinesAfter becoming inactive
GuidelinesAfter becoming inactive
Your app’s size may change
GuidelinesAfter becoming inactive
Your app’s size may changeAdaptivity methods are still called, but nothing is visible
GuidelinesAfter becoming inactive
Your app’s size may changeAdaptivity methods are still called, but nothing is visibleThe system restores the original size
1. App is active and Compact Work☐ Code☐ Fix Bugs☐ Coffee
✅
1. App is active and Compact2. User presses Home button
Work☐ Code☐ Fix Bugs☐ Coffee
✅
1. App is active and Compact2. User presses Home button3. System takes snapshot
Work☐ Code☐ Fix Bugs☐ Coffee
✅
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular5. System takes another snapshot
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular5. System takes another snapshot6. System resizes app to Compact
Home☐ Chores☐ Sleep
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular5. System takes another snapshot6. System resizes app to Compact7. User activates app
Home☐ Chores☐ Sleep
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular5. System takes another snapshot6. System resizes app to Compact7. User activates app8. System shows snapshot from step 3
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
✅
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular5. System takes another snapshot6. System resizes app to Compact7. User activates app8. System shows snapshot from step 39. Fades into live app
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
✅
Home☐ Chores☐ Sleep
Home☐ Chores☐ Sleep
Work☐ Code☐ Fix Bugs☐ Coffee
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular5. System takes another snapshot
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular5. System takes another snapshot6. System resizes app to Compact
Work☐ Code☐ Fix Bugs☐ Coffee
✅
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular5. System takes another snapshot6. System resizes app to Compact7. User activates app
Work☐ Code☐ Fix Bugs☐ Coffee
✅
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular5. System takes another snapshot6. System resizes app to Compact7. User activates app8. System shows snapshot from step 3
Work☐ Code☐ Fix Bugs☐ Coffee
✅
1. App is active and Compact2. User presses Home button3. System takes snapshot4. System resizes app to Regular5. System takes another snapshot6. System resizes app to Compact7. User activates app8. System shows snapshot from step 39. Fades into live app
Work☐ Code☐ Fix Bugs☐ Coffee
✅
GuidelinesAfter becoming inactive
Maintain the same appearance
GuidelinesAfter becoming inactive
Maintain the same appearanceOn deactivation:• Remember your size and state
GuidelinesAfter becoming inactive
Maintain the same appearanceOn deactivation:• Remember your size and state
On size change:• if inactive && newSize == originalSize
- Then apply the remembered state
Primary App
Secondary App
GuidelinesExternal display
GuidelinesExternal display
Only seen by the primary app
GuidelinesPerformance
GuidelinesPerformance
When the size changes, do as little work as possible
GuidelinesPerformance
When the size changes, do as little work as possibleUse completion blocks for slow work
GuidelinesPerformance
When the size changes, do as little work as possibleUse completion blocks for slow workIn animation blocks, don’t call layoutIfNeeded
GuidelinesPerformance
When the size changes, do as little work as possibleUse completion blocks for slow workIn animation blocks, don’t call layoutIfNeededUse setNeedsLayout
MultitaskingAdapting to dynamic size changes
StrategiesGuidelines
Adopting Multitasking in iOS 9Summary
Adopt Multitasking in your appUse AdaptivityYou can deliver a great user experience
More Information
DocumentationWhat’s New in iOSiOS App Programming GuideAdopting Multitasking Enhancements on iPad
Sample CodeAdaptivePhotosLister
http://developer.apple.com/ios
Technical SupportApple Developer ForumsDeveloper Technical Support