Despite the demise of iPad in recent years, Apple put many efforts to improve the user experience of iPad. Multitasking is somewhat long-wanted feature in iPad. This session is introducing how developers to embrace the new technologies in Multitasking.
Great article about multitasking
Related Sesssion: Multitasking Esstials for Media-based Apps on iPad in iOS 9, Optimizing Your App for Multitasking in iOS
Slide Over
right slide over app has compact horizontal size class
Split View
Adaptivity
iPad Multitasking is enabled by default in new project
Existing app
UIRequiresFullscreen
key UIScreen.bounds returns windows.bounds Only need to care The current UIWindow
* a UILayoutGuide for legible region in a UIView
* smartly adjust when windows bounds change
```UITableView.cellLayoutMarginsFollowReadableWidth
Related Sesssion: Building Adaptive apps with UIKit (WWDC14)
//not apply for multitasking as you may be much rooms in different direction
if UIInterfaceOrientationIsLandscape(interfaceOrientation) {
}
//encourage
if view.bounds.size.width > view.bounds.size.height {
}
//encourage
if traitCopllection.horizontalSizeClass == .Regular
}
in iOS 9 no need to set frame on window as iOS 9 figure out for you so it is okay to initial UIWindow without frame
var window = UIWindow()
or
UIWindow *window = [[UIWindow alloc] init];
PresentationController
Related Sesssion: Building Adaptive apps with UIKit (WWDC14)
UIAdaptivePresentationControllerDelegate
te response the size changes
Popover To handle popover arrow pointing to right position, these below are suggested.
popoverPresentationController.barButtonItem = sender
OR
popoverPresentationController.sourceView = button
popoverPresentationController.sourceRect = button.bounds
Keyboard listen to the following notification when related keyboard
UIKeyboardWillShowNotification
UIKeyboardDidShowNotification
UIKeyboardWillHideNotification
UIKeyboardDidHideNotification
UIKeyboardWillChangeFrameNotification
UIKeyboardDidChangeFrameNotification
let label = UILabel()
let readableContentGuide = self.view.readableContentGuide
let constraints = [label.leadingAnchor.constraintEqualToAnchor(
readableContentGuide.leadingAnchor), label.trailingAnchor.constraintEqualToAnchor(
readableContentGuide.trailingAnchor) NSLayoutConstraint.activateConstraints(constraints)
Xcode Support
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
}
//do below if animation is needed for size class changes
let animation = {
(context: UIViewControllerTransitionCoordinatorContext) -> Void in
// Change your UI here. It will animate from the old to the new.
}
coordinator.animateAlongsideTransition(animation, completion: nil)
}
//another callback for overriding
override func viewWillTransitionToSize(
size: CGSize,
withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator)
{
}
5: High-level API
* ```UIStackView``` *Related session Mysteries of Auto Layout, Part 1*
6: SplitViewController
Demo Project:AdaptivePhotos
layoutIfneeded
setNeedsLayout
to mark any views and system will layout for you in the animation