What’s New in Cocoa Touch...What’s New in Cocoa Touch Session 202 Luke Hiesterman UIKit Engineer...

Post on 23-Sep-2020

1 views 0 download

Transcript of What’s New in Cocoa Touch...What’s New in Cocoa Touch Session 202 Luke Hiesterman UIKit Engineer...

© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

#WWDC14

What’s New in Cocoa Touch

Session 202 Luke Hiesterman UIKit Engineer

Frameworks

iOS 8 Adaptivity

Adaptive View Controllers

Adaptive View Controllers

Adaptive View Controllers

Adaptive Presentations

Adaptive Presentations

Adaptive Presentations

Adaptive Text and Tables

Adaptive Text and Tables

Adaptive Text and Tables

App Extensions

App Extensions

Adaptive LayoutOrientations, sizes, and margins

Adaptive LayoutsInterface orientation

Adaptive LayoutsInterface orientation

Adaptive LayoutsInterface orientation

Adaptive LayoutsInterface orientation

768

1024

Adaptive LayoutsInterface orientation

768

1024

1024

768

Adaptive LayoutsInterface orientation

1024

768

Adaptive LayoutsSizing

Adaptive LayoutsSizing

Regular Width

Regular Height

Size ClassesThe new interface orientation

Size Classes

Canvas size rather than interface orientation

The new interface orientation

Size Classes

Canvas size rather than interface orientation

Independent horizontal and vertical-size classes

The new interface orientation

Size Classes

Canvas size rather than interface orientation

Independent horizontal and vertical-size classes• Compact

The new interface orientation

Size Classes

Canvas size rather than interface orientation

Independent horizontal and vertical-size classes• Compact

• Regular

The new interface orientation

Adaptive LayoutsSizing

Regular Width

Regular Height

Adaptive LayoutsSizing

Compact Width

Normal Height

Adaptive LayoutsSizing

Compact Width

Compact Height

Trait CollectionsEverything you need to know to layout

Trait CollectionsEverything you need to know to layout

horizontalSizeClass

Trait CollectionsEverything you need to know to layout

horizontalSizeClass

verticalSizeClass

Trait CollectionsEverything you need to know to layout

horizontalSizeClass

verticalSizeClass

displayScale

Trait CollectionsEverything you need to know to layout

horizontalSizeClass

verticalSizeClass

displayScale

userInterfaceIdiom

Trait CollectionsEverything you need to know to layout

override func traitCollectionDidChange(previousTraitCollection: UITraitCollection!) { let currentTraits = self.traitCollection let newLayout = currentTraits.horizontalSizeClass == UIUserInterfaceSizeClass.Compact ? self.squaresLayout : self.rectanglesLayout self.collectionView.setCollectionViewLayout(newLayout, animated: true) }

Trait CollectionsEverything you need to know to layout

override func traitCollectionDidChange(previousTraitCollection: UITraitCollection!) { let currentTraits = self.traitCollection let newLayout = currentTraits.horizontalSizeClass == UIUserInterfaceSizeClass.Compact ? self.squaresLayout : self.rectanglesLayout self.collectionView.setCollectionViewLayout(newLayout, animated: true) }

Trait CollectionsEverything you need to know to layout

override func traitCollectionDidChange(previousTraitCollection: UITraitCollection!) { let currentTraits = self.traitCollection let newLayout = currentTraits.horizontalSizeClass == UIUserInterfaceSizeClass.Compact ? self.squaresLayout : self.rectanglesLayout self.collectionView.setCollectionViewLayout(newLayout, animated: true) }

Trait CollectionsEverything you need to know to layout

override func traitCollectionDidChange(previousTraitCollection: UITraitCollection!) { let currentTraits = self.traitCollection let newLayout = currentTraits.horizontalSizeClass == UIUserInterfaceSizeClass.Compact ? self.squaresLayout : self.rectanglesLayout self.collectionView.setCollectionViewLayout(newLayout, animated: true) }

Trait CollectionsEverything you need to know to layout

override func traitCollectionDidChange(previousTraitCollection: UITraitCollection!) { let currentTraits = self.traitCollection let newLayout = currentTraits.horizontalSizeClass == UIUserInterfaceSizeClass.Compact ? self.squaresLayout : self.rectanglesLayout self.collectionView.setCollectionViewLayout(newLayout, animated: true) }

Adaptive Margins

Layout Guide

Layout Guide

Adaptive Margins

Layout Guide

Layout MarginLayout Margin

Layout Guide

Adaptive Margins

Adaptive MarginsAuto Layout support

Adaptive MarginsAuto Layout support

New margin NSLayoutAttributes

Adaptive MarginsAuto Layout support

New margin NSLayoutAttributes• LeftMargin

Adaptive MarginsAuto Layout support

New margin NSLayoutAttributes• LeftMargin

• RightMargin

Adaptive MarginsAuto Layout support

New margin NSLayoutAttributes• LeftMargin

• RightMargin

• LeadingMargin

Adaptive MarginsAuto Layout support

New margin NSLayoutAttributes• LeftMargin

• RightMargin

• LeadingMargin

• …etc

More Adaptive Layout Information

• Building Adaptive Apps with UIKit Mission Wednesday 10:15AM

Adaptive View Controllers

RotationWhat is rotation, really?

RotationWhat is rotation, really?

Rotation is an animated bounds change

RotationWhat is rotation, really?

Rotation is an animated bounds change

RotationWhat is rotation, really?

Rotation is an animated bounds change

RotationWhat is rotation, really?

RotationWhat is rotation, really?

Compact Width

Regular Height

RotationWhat is rotation, really?

Regular Width

Compact Height

RotationDeprecations

RotationDeprecations

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation; -(BOOL)shouldAutomaticallyForwardRotationMethods; -(UIInterfaceOrientation)interfaceOrientation; -(void)rotatingHeaderView; -(void)rotatingFooterView;

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) { [self.collectionView.collectionViewLayout.numberOfColumns = [self columnsForSize:size]; } completion:nil]; }

RotationNew hotness

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) { [self.collectionView.collectionViewLayout.numberOfColumns = [self columnsForSize:size]; } completion:nil]; }

RotationNew hotness

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) { [self.collectionView.collectionViewLayout.numberOfColumns = [self columnsForSize:size]; } completion:nil]; }

RotationNew hotness

Adaptive View Controller HierarchiesSimplifying and unifying code

Adaptive View Controller HierarchiesSimplifying and unifying code

Split View Controller

Adaptive View Controller HierarchiesSimplifying and unifying code

Navigation Controller

Split View Controller

Adaptive View Controller HierarchiesSimplifying and unifying code

Adaptive View Controller HierarchiesSimplifying and unifying code

Split View Controller

Adaptive View Controller HierarchiesSimplifying and unifying code

Navigation Controller

Split View Controller

Adaptive View Controller Hierarchies

Adaptive View Controller Hierarchies

Adaptive View Controller Hierarchies

UISplitViewControlleriOS 8 workhorse

UISplitViewControlleriOS 8 workhorse

Now available on all devices

UISplitViewControlleriOS 8 workhorse

Now available on all devices

Handles primary-secondary pattern transparently

UISplitViewControlleriOS 8 workhorse

Now available on all devices

Handles primary-secondary pattern transparently

Enhanced customizability

More View Controller Information

• View Controller Advancements in iOS 8 Mission Wednesday 9:00AM

Adaptive PresentationsPopovers, search results, and alerts

View Controller PresentationsPresent how you want, where you want, when you want

View Controller PresentationsPresent how you want, where you want, when you want

View Controller PresentationsPresent how you want, where you want, when you want

PopoversAdaptive Presentations

Popovers

Natural presentation in regular width

Adaptive Presentations

Adaptive PresentationsPopovers

Natural presentation in regular width

FullScreen or OverFullScreen in compact width

Adaptive Search Results

Adaptive Search Results

UISearchDisplayController replaced by UISearchController

Adaptive Search Results

UISearchDisplayController replaced by UISearchController

UIViewController subclass

Adaptive Search Results

UISearchDisplayController replaced by UISearchController

UIViewController subclass

All the power of adaptive presentations and hierarchies is included

Adaptive Search Results

UISearchDisplayController replaced by UISearchController

UIViewController subclass

All the power of adaptive presentations and hierarchies is included

Customizable UI

Adaptive Alerts

Adaptive Alerts

UIAlertController replaces UIAlertView and UIActionSheet

Adaptive Alerts

UIAlertController replaces UIAlertView and UIActionSheet

UIAlertController is a view controller subclass

Adaptive Alerts

UIAlertController replaces UIAlertView and UIActionSheet

UIAlertController is a view controller subclass

Adapts styling to context

Adaptive Alerts

Adaptive Alerts

More Adaptive Presentations

• A Look Inside Presentation Controllers Mission Thursday 11:30AM

Testing with the iOS Simulator

Testing with the iOS Simulator

Testing with the iOS Simulator

Customizing User Interface

Visual Effects

Visual Effects

UIVisualEffectView

Visual Effects

UIVisualEffectView• UIBlurEffect

Visual Effects

UIVisualEffectView • UIBlurEffect

• UIVibrancyEffect

Visual Effects

UIVisualEffectView • UIBlurEffect

• UIVibrancyEffect

Vibrant Separators

Image Assets

override func viewDidAppear(animated: Bool) { self.imageView.image = UIImage(named: "My-Dog", inBundle: nil, compatibleWithTraitCollection: self.traitCollection) }

Image Assets

override func viewDidAppear(animated: Bool) { self.imageView.image = UIImage(named: "My-Dog", inBundle: nil, compatibleWithTraitCollection: self.traitCollection) }

Image Assets

override func viewDidAppear(animated: Bool) { self.imageView.image = UIImage(named: "My-Dog", inBundle: nil, compatibleWithTraitCollection: self.traitCollection) }

Image Assets

override func viewDidAppear(animated: Bool) { self.imageView.image = UIImage(named: "My-Dog", inBundle: nil, compatibleWithTraitCollection: self.traitCollection) }

Condensing Bars

Condensing Bars

Condensing Bars

Condensing Bars

More Interface Customizations

• Creating Custom iOS User Interfaces Marina Wednesday 3:15PM

Self-sizing Table Cells

Self-sizing Table Cells

Variable row heights without tableView:heightForRowAtIndexPath:

Self-sizing Table Cells

Variable row heights without tableView:heightForRowAtIndexPath:

Table cells can encapsulate sizing logic

Self-sizing Table Cells

Variable row heights without tableView:heightForRowAtIndexPath:

Table cells can encapsulate sizing logic

Supports Auto Layout

Self-sizing Table Cells

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)identifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@“V:|-myTextView-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(myTextView)]]; ! [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@“H:|-myTextView-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(myTextView)]]; ! } return self; }

Self-sizing Table Cells

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)identifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@“V:|-myTextView-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(myTextView)]]; ! [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@“H:|-myTextView-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(myTextView)]]; ! } return self; }

Self-sizing Table Cells

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)identifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@“V:|-myTextView-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(myTextView)]]; ! [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@“H:|-myTextView-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(myTextView)]]; ! } return self; }

Self-sizing Table Cells

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)identifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@“V:|-myTextView-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(myTextView)]]; ! [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@“H:|-myTextView-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(myTextView)]]; ! } return self; }

More Table Views

• What’s New in Table and Collection Views Presidio Thursday 10:15AM

App Extensions

App ExtensionsExtending the system

App ExtensionsExtending the system

App ExtensionsExtending the system

App ExtensionsExtending the system

App ExtensionsExtending the system

App ExtensionsExtending the system

App ExtensionsExtending the system

App ExtensionsExtending the system

Photos

App ExtensionsExtending the system

Photos

Sharing

App ExtensionsExtending the system

Photos

Sharing

Widgets

App ExtensionsExtending the system

Photos

Sharing

Widgets

Actions without UI

App ExtensionsExtending the system

Photos

Sharing

Widgets

Actions without UI

Document providers

App ExtensionsExtending the system

Photos

Sharing

Widgets

Actions without UI

Document providers

Custom keyboards

More App Extensions

• Creating Extensions for iOS and OS X, Part 1 Mission Tuesday 2:00PM

• Creating Extensions for iOS and OS X, Part 2 Mission Wednesday 11:30AM

Notification Updates

Notification Updates

Notification Updates

User approval required for UI only

Notification Updates

User approval required for UI only

Notifications can have user actions

Notification Updates

User approval required for UI only

Notifications can have user actions

Location-based notifications

Notification Updates

User approval required for UI only

Notifications can have user actions

Location-based notifications

Increased push payload size (256 bytes 1k)

More Notifications

• What’s New in iOS Notifications Nob Hill Wednesday 2:00PM

Document Picker

UIDocumentPickerViewController

UIDocumentPickerViewController

UIDocumentPickerViewController

System UI for selecting documents

UIDocumentPickerViewController

System UI for selecting documents• Local documents

UIDocumentPickerViewController

System UI for selecting documents• Local documents

• iCloud documents

UIDocumentPickerViewController

System UI for selecting documents• Local documents

• iCloud documents

• Third-party document providers

More Document Support

• Building a Document-based App Marina Thursday 11:30AM

SDK Modernization

SDK Modernization

SDK Modernization

NS_DESIGNATED_INITIALIZER

SDK Modernization

NS_DESIGNATED_INITIALIZER

id instancetype

SDK Modernization

NS_DESIGNATED_INITIALIZER

id instancetype

Additional @properties

Handoff

Handoff

Handoff

User activities shared between multiple devices

Handoff

User activities shared between multiple devices

Built-in support in UIKit and AppKit

Handoff

• Adopting Handoff on iOS and OS X Mission Wednesday 2:00PM

More Goodies in iOS

Notification CenterCustom widgets

Photos

• Introducing the Photos Framework Nob Hill Thursday 10:15AM

Photos

• Introducing the Photos Framework Nob Hill Thursday 10:15AM

Read/write access to photos library

Photos

• Introducing the Photos Framework Nob Hill Thursday 10:15AM

Read/write access to photos library

Custom CoreImage filters

CloudKit

• Introducing CloudKit Mission Tuesday 3:15PM

• Advanced CloudKit Mission Thursday 3:15PM

CloudKit

More control over data you put in the cloud

• Introducing CloudKit Mission Tuesday 3:15PM

• Advanced CloudKit Mission Thursday 3:15PM

CloudKit

More control over data you put in the cloud

Build client-server apps without building a server

• Introducing CloudKit Mission Tuesday 3:15PM

• Advanced CloudKit Mission Thursday 3:15PM

HealthKit

• Introducing HealthKit Mission Tuesday 10:15AM

HealthKit

Access information from biometric accessories in one framework

• Introducing HealthKit Mission Tuesday 10:15AM

HomeKit

• Introducing HomeKit Mission Tuesday 4:30PM

HomeKit

Access information from connected home accessories in one framework

• Introducing HomeKit Mission Tuesday 4:30PM

Local Authentication

• Keychain and Authentication with Touch ID Nob Hill Wednesday 10:15AM

Local Authentication

Leverage biometric authentication in your app

• Keychain and Authentication with Touch ID Nob Hill Wednesday 10:15AM

Local Authentication

Leverage biometric authentication in your app• TouchID

• Keychain and Authentication with Touch ID Nob Hill Wednesday 10:15AM

SceneKit

• What's New in SceneKit Pacific Heights Thursday 10:15AM

• Building a Game with SceneKit Pacific Heights Thursday 11:30AM

SceneKit

Cross-platform 3D rendering for iOS

• What's New in SceneKit Pacific Heights Thursday 10:15AM

• Building a Game with SceneKit Pacific Heights Thursday 11:30AM

Core Location

• What's New in Core Location Marina Tuesday 2:00PM

• Taking Core Location Indoors Marina Tuesday 3:15PM

Core Location

Indoor location

• What's New in Core Location Marina Tuesday 2:00PM

• Taking Core Location Indoors Marina Tuesday 3:15PM

Core Location

Indoor location

Power-saving location updates

• What's New in Core Location Marina Tuesday 2:00PM

• Taking Core Location Indoors Marina Tuesday 3:15PM

Core Location

Indoor location

Power-saving location updates

Always vs. when-in-use user approval

• What's New in Core Location Marina Tuesday 2:00PM

• Taking Core Location Indoors Marina Tuesday 3:15PM

Summary

Summary

Simplify layout with size classes

Summary

Simplify layout with size classes

Unify iPhone and iPad code with adaptive view controllers

Summary

Simplify layout with size classes

Unify iPhone and iPad code with adaptive view controllers

Integrate into the system experience with app extensions

Summary

Simplify layout with size classes

Unify iPhone and iPad code with adaptive view controllers

Integrate into the system experience with app extensions

Expand your tool set with new frameworks in iOS 8

More Information

Jake Behrens Frameworks Evangelist behrens@apple.com

Documentation http://developer.apple.com

Apple Developer Forums http://devforums.apple.com

• Introducing HealthKit Mission Tuesday 10:15AM

• What's New in Core Location Marina Tuesday 2:00PM

• Introducing CloudKit Mission Tuesday 3:15PM

• Taking Core Location Indoors Marina Tuesday 3:15PM

• Introducing HomeKit Mission Tuesday 4:30PM

• Keychain and Authentication with Touch ID Nob Hill Wednesday 10:15AM

• Advanced CloudKit Mission Thursday 3:15PM

Related Sessions

Related Sessions

• Introducing the Photos Framework Nob Hill Thursday 10:15AM

• What's New in SceneKit Pacific Heights Thursday 10:15AM

• Building a Game with SceneKit Pacific Heights Thursday 11:30AM

Labs

• Cocoa Touch Lab Frameworks Lab A Tuesday 12:30PM

• Cocoa Touch Lab Frameworks Lab A Wednesday 11:30AM

• Cocoa Touch Lab Frameworks Lab A Thursday 2:00PM