Multitasking
The Hard Way
@micheletitolo

Lead Software Engineer, Capital One
What We’ll Cover
What are Multitasking and Adaptivity?

Creating Adaptivity

Tips, Tricks, and Gotchas
What Is Multitasking?
Adaptivity
Compact
Compact
Regular
Regular
✔
✔✔
x
Creating Adaptivity
• Launch.storyboard

• Full iPad rotation

• UITraitCollection
Mechanics
Apps Must Use A
Launch.Storyboard
Apps Must Allow
Full Rotation
Setting in Info.plist
UITraitCollection
horizontalSizeClass

verticalSizeClass
UITraitEnvironment

UIContentContainer
UITraitEnvironment
traitCollection
traitCollectionDidChange
UIView
UIViewController
UIPresentationController
UIContentContainer
viewWillTransitionToSize
willTransitionToTraitCollection
UIViewController
UIPresentationController
Different Use Cases
Responding To Changes
Multitasking Order
•applicationWillResignActive
•willTransitionToTraitCollection
•viewWillTransitionToSize
•traitCollectionDidChange
•applicationDidBecomeActive
Multitasking Order
•applicationWillResignActive
•willTransitionToTraitCollection
•viewWillTransitionToSize
•traitCollectionDidChange
•applicationDidBecomeActive
Multitasking Order
•applicationWillResignActive
•willTransitionToTraitCollection
•viewWillTransitionToSize
•traitCollectionDidChange
•applicationDidBecomeActive
Multitasking Order
Slideovers Are Still Inactive
Becoming Adaptive
Tools
Installed Views

Installed Constraints

Conditional Constraint Constants
Demo
Only Constraint Constants
Can Change
Tips, Tricks,
Gotchas
Autolayout
Rotation APIs
UISplitViewController
Compact == Modal
Still Can’t Be Pushed
Can Be Embedded
UIPopoverPresentationController
Also Fullscreen In Compact
UIPresentationController
Set modalPresentationStyle
To .Custom
adaptivePresentationStyleFor

TraitCollection:
UICollectionView
Don’t rely on
shouldInvalidateLayoutForBoundsChange
prepareLayout()
may have incorrect traits
use both
willTransitionToTraitCollection,
viewWillTransitionToSize
Bugs!
iPhone 2 NowiPhone 3.2 iOS 6
iPhone 5
iOS 9iOS 8
iPad iPhone 6/6+ iPad Pro
iOS 5 iOS 7
iPhone 2 NowiPhone 3.2 iOS 6
iPhone 5
iOS 9iOS 8
iPad iPhone 6/6+ iPad Pro
UIViewController
iOS 5 iOS 7
iPhone 2 NowiPhone 3.2 iOS 6
iPhone 5
iOS 9iOS 8
UISplitViewController
iPad iPhone 6/6+ iPad Pro
UIViewController
UIPopoverController
iOS 5 iOS 7
iPhone 2 NowiPhone 3.2 iOS 6
iPhone 5
iOS 9iOS 8
UISplitViewController
iPad iPhone 6/6+ iPad Pro
UIViewController
UIPopoverController
UIViewController Containment
iOS 5 iOS 7
iPhone 2 NowiPhone 3.2 iOS 6
iPhone 5
iOS 9iOS 8
UISplitViewController
Autolayout
iPad iPhone 6/6+ iPad Pro
UICollectionView
UIViewController
UIPopoverController
UIViewController Containment
iOS 5 iOS 7
iPhone 2 NowiPhone 3.2 iOS 6
iPhone 5
iOS 9iOS 8
UISplitViewController
Autolayout
iPad iPhone 6/6+ iPad Pro
UICollectionView
UIViewController
UIPopoverController UITraitCollection
UITraitEnvironment
UIViewController Containment
iOS 5 iOS 7
iPhone 2 NowiPhone 3.2 iOS 6
iPhone 5
iOS 9iOS 8
UISplitViewController
Autolayout
iPad iPhone 6/6+ iPad Pro
UICollectionView
UIViewController
UIPopoverController
UIContentContainer
UITraitCollection
UITraitEnvironment
UIViewController Containment
iOS 5 iOS 7
iPhone 2 NowiPhone 3.2 iOS 6
iPhone 5
iOS 9iOS 8
UISplitViewController
Autolayout
iPad iPhone 6/6+ iPad Pro
Multitasking
UICollectionView
UIViewController
UIPopoverController
UIStackView
UIContentContainer
UITraitCollection
UITraitEnvironment
UIViewController Containment
iOS 5 iOS 7
UITraitCollection Support
Has Been Added To
Older Components
Storyboards and Xibs
Frames Change When
Size Class Changes
First Time In A New Size Class
Adds Info To File
Misplaced Views In
Different Size Classes
Installed Views And Constraints Only
Work From Storyboards And Xibs
Conditional Constraint Constants Only
Work From Storyboards And Xibs
Any x Any
Constraints Must Be Set
For Any x Any
Even though no devices have that 

size class configuration
Pick A Size Class To Use
For Any x Any
Interface Builder Warnings
UI Will Look Weird
Use Constraint Priorities
Questions?
https://github.com/mtitolo/space

https://github.com/mtitolo/primaries
Photo Credits
• https://unsplash.com/photos/iiaXf9xmgbM

• https://unsplash.com/photos/85hdWh8KtR4

• https://unsplash.com/photos/l5Tzv1alcps

Multitasking