SlideShare a Scribd company logo
Evan Maloney Distinguished Engineer, Gilt Groupe
tvOS,
the Focus Engine
& Swift
Discoveries from building “Gilt on TV”
Demoing “Gilt on TV”
tvOS vs. iOS: Similarities
• Most of tvOS is a direct subset of iOS
• Familiarity with UIKit will serve you well with tvOS
• But, some of the things you may expect won’t be there
• No web views
• Certain frameworks like MultipeerConnectivity aren’t
available
• Several UIControls (pickers, steppers, sliders, etc.)
• Can use Interface Builder (or not), Swift or Objective-C
tvOS tvOS vs. iOS
tvOS vs. iOS: Differences
• User interaction is indirect touch
• Unlike an iPhone or iPad, the user doesn’t directly
manipulate the UI — uses indirect touch like a trackpad
• Directionality is reversed from iOS
• Relies on the Focus Engine for determining UI state
• Only on tvOS — adds extensions to UIViewController,
UIView, UITableView, UICollectionView, etc.
tvOS tvOS vs. iOS
Focus Engine Philosophy
• The Focus Engine is intended to be a black box
• You provide inputs that determine the initially focused view
• You define where the user can go
• Provide some visual indication of focusability
• Provide an animation or visual state change upon
becoming focused (often handled by the tvOS SDK)
• Once your view controller is onscreen and the initial view has
become focused, the user should be in control of all state
changes
• It is considered rude to forcibly change focus on the user
tvOS The Focus Engine
What is “Focus”?
• A focusable view is one that the user can select with the touch
remote
• Being focusable implies that the user can perform an action on
the view
• Focusable views are often “pressable,” like UIButtons
• A focused view renders itself to stand out from the others
onscreen, usually with one or more of the following attributes:
• A larger size
• A drop shadow
• A highlight color or border
tvOS Focus
How does the Focus Engine work?
• When the view hierarchy changes, the Focus Engine creates a
map of the visible focusable views
• If the user navigates in a given direction, the Focus Engine
looks for a focusable view in that direction, taking into account
each candidate view’s focus frame size & relative position
• A candidate for receiving next focus is selected
• If the candidate is a table or collection cell, the relevant
delegate is given an opportunity to reject focus and another
candidate may be selected
tvOS The Focus Engine
tvOS The Focus Engine
Gilt on TV 1.0 — Women’s Store
tvOS The Focus Engine
Focus Frames
How does a view become “Focusable”?
• By default, the following views are focusable:
• UIControls
• Table cells and collection cells
• Can be overridden by UICollectionViewDelegate
• UIViews that are not otherwise focusable can be made so by
overriding canBecomeFocused()
• The focused property of a UIView indicates whether the
view is currently in focus
tvOS Focus
How does a view become “Focused”?
• When a view controller is displayed, the focus engine asks for
the preferredFocusedView from the relevant views and
view controllers to determine which view gets initial focus
• From there, the user controls focus using the remote
• When the user swipes in a given direction, the Focus Engine
selects an appropriate focusable view to get next focus
• Developers can use the UIFocusUpdateContext to
coordinate animations when views go into and out of focus
tvOS Focus
tvOS The Focus Engine
Gilt on TV 1.0 — Men’s Store (scrolled)
tvOS The Focus Engine
Focus Frames
tvOS The Focus Engine
Changing Focus — Unambiguous Move
tvOS The Focus Engine
Ambiguous Move — Focus Engine Chooses
tvOS The Focus Engine
Sale View
tvOS The Focus Engine
Focus Frames
tvOS The Focus Engine
Navigating to “Buy Now” — A Near Miss
The Dilemma
tvOS Focus Guides
How could you solve it?
You can’t assume the Focus Engine “sees” focusable views that
aren’t in the direct path of the swipe direction
tvOS solution
Allow a UIView to report to a focus frame that’s larger than the
view’s native frame
1. Call parentView.addLayoutGuide(UIFocusGuide)
2. Set the focus guide’s preferredFocusedView
3. Add Auto Layout constraints using the focus guide as you
would any UIView
tvOS Focus Guides
A focus guide defines a screen rectangle
tvOS Focus Guides
Focus is forwarded to the preferredFocusedView
tvOS Focus Guides
Allowing a small button to respond to a large frame
Handling scrolling content
• You will not be able to present scrolling content in the same
way you do in iOS
• User can only scroll by navigating to something focusable
within a scroll view
• The Focus Engine only pays attention to focusable non-hidden
views with non-zero alphas that have at least one pixel within
the screen bounds
• Focusable views and cells that are offscreen won’t be visible
to the Focus Engine, so the user can’t navigate to them
tvOS The Focus Engine
tvOS Focus Guides
Product View
tvOS Focus Guides
Focus Frames
Other challenges for tvOS developers
• Apparently a lot of people rely on web views for mission-critical
screens within their apps — they will be forced to rethink
• Restrictions on App Store binaries:
• Applications need to be submitted as Bitcode binaries
• This includes embedded frameworks, which makes many
third-party closed-source frameworks unusable in tvOS
• On-device testing — Very few people have development
devices, and simulator testing may not reveal all problems
tvOS tvOS Development
Fun things about tvOS development
• Some of the iOS pain points don’t exist on tvOS
• Apple TVs will often be used to stream video — unlike with
mobile devices, tvOS developers can assume the presence
of low-latency, always-on, high-bandwidth networks
• Don’t need to think about screen rotation or size class
changes
• Only need to develop for a single screen resolution — for
now
tvOS tvOS Development
A few words about Swift
and finally…
Swift — Pain Points
• The language is still changing, so major releases of Xcode
often require a bit of code rewriting
• Usually minimal, and the language is improving as a result
• Developer tooling still needs work
• Debugger sometimes refuses to cough up variable values
• Compiler errors can be vague or misleading
• Compiler stability is sometimes an issue
• Heavy use of Swift frameworks sometimes doesn’t play
nicely with “whole module optimization”
• Binaries may not be compatible across compiler versions
tvOS Swift
Swift — Advantages
• Swift may not be mature, but it is ready for prime-time
• Swift absolutely fulfills the promise of more efficient
development
• An entire class of errors that used to require runtime
debugging is now caught by the compiler
• Building a stable app takes much less work than Objective-C
• I probably spent about ¼ the time debugging as I would
have had to do in ObjC
• Coding in Swift is an absolute pleasure
tvOS Swift
Swift — The Verdict
tvOS Swift
Do it!
You know you’ll “go Swift” eventually…
…and the longer you wait, the more you’ll be kicking yourself
for not having done it sooner once you finally do!
Evan Maloney Distinguished Engineer, Gilt Groupe
A parting gift for you
https://github.com/emaloney/CleanroomLogger
CleanroomLogger — A pure Swift logging engine
Simple, lightweight & performant
Code goodies!

More Related Content

What's hot

SPONGES AND THEIR POTENTIAL USES by Ranjith Edirisinghe
SPONGES AND THEIR POTENTIAL USES by Ranjith EdirisingheSPONGES AND THEIR POTENTIAL USES by Ranjith Edirisinghe
SPONGES AND THEIR POTENTIAL USES by Ranjith Edirisinghe
apaari
 
Breeding Biology & Parameters of Finfish and Shellfish by Syekat
Breeding Biology & Parameters of Finfish and  Shellfish by SyekatBreeding Biology & Parameters of Finfish and  Shellfish by Syekat
Breeding Biology & Parameters of Finfish and Shellfish by Syekat
Nazmul Haque Syekat, Noakhai Science & Technology University.
 
Recirculating Aquaculture System
Recirculating Aquaculture SystemRecirculating Aquaculture System
Recirculating Aquaculture System
vishal solanki
 
endemic freshwater fishes in the philippines
endemic freshwater fishes in the philippinesendemic freshwater fishes in the philippines
endemic freshwater fishes in the philippines
cmsavanag4399
 
Presentation 1.2 New paradigm for controlling AHPND in intensive culture syst...
Presentation 1.2 New paradigm for controlling AHPND in intensive culture syst...Presentation 1.2 New paradigm for controlling AHPND in intensive culture syst...
Presentation 1.2 New paradigm for controlling AHPND in intensive culture syst...
ExternalEvents
 
Shrimp Farming
Shrimp Farming Shrimp Farming
Grouper
GrouperGrouper
Grouper
Meggy Rard
 
Tilapia seed prodn & hatchery mgt
Tilapia seed prodn & hatchery  mgtTilapia seed prodn & hatchery  mgt
Tilapia seed prodn & hatchery mgt
Mahbub Alam Khan Shahin
 
Aquaculture 3 - Food Safety Practices for Aquaculture Production 2013
Aquaculture 3 - Food Safety Practices for Aquaculture Production 2013Aquaculture 3 - Food Safety Practices for Aquaculture Production 2013
Aquaculture 3 - Food Safety Practices for Aquaculture Production 2013
Asian Food Regulation Information Service
 
Case Study Presentation
Case Study PresentationCase Study Presentation
Case Study Presentation
Stephanie Bachmann
 
Estuary Presentation
Estuary PresentationEstuary Presentation
Estuary Presentation
Matthew_Ullman
 
POST HARVEST TECHNOLOGY BY BALACHANDRAN
POST HARVEST TECHNOLOGY BY BALACHANDRANPOST HARVEST TECHNOLOGY BY BALACHANDRAN
POST HARVEST TECHNOLOGY BY BALACHANDRAN
SHUBHAM PATIDAR FISHERIES ADDAA
 
Tubifex worm as live feed in Aquaculture
Tubifex worm as live feed in AquacultureTubifex worm as live feed in Aquaculture
Tubifex worm as live feed in Aquaculture
MaheshiWeerasuriya
 
Biofloc information
Biofloc informationBiofloc information
Biofloc information
tuannhi5
 
Biofloc Technology
Biofloc TechnologyBiofloc Technology
Biofloc Technology
Maryam Hameed
 
Shrimp Culture: Culture of Tiger Shrimp (Penaeus monodon)
Shrimp Culture: Culture of Tiger Shrimp (Penaeus monodon)Shrimp Culture: Culture of Tiger Shrimp (Penaeus monodon)
Shrimp Culture: Culture of Tiger Shrimp (Penaeus monodon)
Ratul Chakraborty
 
Clinical Case Study PPT
Clinical Case Study PPTClinical Case Study PPT
Clinical Case Study PPT
Kaytlin Fischer
 
SHRIMP HEALTH MANAGEMENT
SHRIMP HEALTH MANAGEMENTSHRIMP HEALTH MANAGEMENT
SHRIMP HEALTH MANAGEMENT
Thavasimuthu citarasu
 
Fish for all: role of biotechnology in improving nutrition
Fish for all: role of biotechnology in improving nutritionFish for all: role of biotechnology in improving nutrition
Fish for all: role of biotechnology in improving nutrition
ExternalEvents
 
Types of coral reefs and its distribution
Types of coral reefs and its distributionTypes of coral reefs and its distribution
Types of coral reefs and its distribution
College of Fisheries, KVAFSU, Mangalore, Karnataka
 

What's hot (20)

SPONGES AND THEIR POTENTIAL USES by Ranjith Edirisinghe
SPONGES AND THEIR POTENTIAL USES by Ranjith EdirisingheSPONGES AND THEIR POTENTIAL USES by Ranjith Edirisinghe
SPONGES AND THEIR POTENTIAL USES by Ranjith Edirisinghe
 
Breeding Biology & Parameters of Finfish and Shellfish by Syekat
Breeding Biology & Parameters of Finfish and  Shellfish by SyekatBreeding Biology & Parameters of Finfish and  Shellfish by Syekat
Breeding Biology & Parameters of Finfish and Shellfish by Syekat
 
Recirculating Aquaculture System
Recirculating Aquaculture SystemRecirculating Aquaculture System
Recirculating Aquaculture System
 
endemic freshwater fishes in the philippines
endemic freshwater fishes in the philippinesendemic freshwater fishes in the philippines
endemic freshwater fishes in the philippines
 
Presentation 1.2 New paradigm for controlling AHPND in intensive culture syst...
Presentation 1.2 New paradigm for controlling AHPND in intensive culture syst...Presentation 1.2 New paradigm for controlling AHPND in intensive culture syst...
Presentation 1.2 New paradigm for controlling AHPND in intensive culture syst...
 
Shrimp Farming
Shrimp Farming Shrimp Farming
Shrimp Farming
 
Grouper
GrouperGrouper
Grouper
 
Tilapia seed prodn & hatchery mgt
Tilapia seed prodn & hatchery  mgtTilapia seed prodn & hatchery  mgt
Tilapia seed prodn & hatchery mgt
 
Aquaculture 3 - Food Safety Practices for Aquaculture Production 2013
Aquaculture 3 - Food Safety Practices for Aquaculture Production 2013Aquaculture 3 - Food Safety Practices for Aquaculture Production 2013
Aquaculture 3 - Food Safety Practices for Aquaculture Production 2013
 
Case Study Presentation
Case Study PresentationCase Study Presentation
Case Study Presentation
 
Estuary Presentation
Estuary PresentationEstuary Presentation
Estuary Presentation
 
POST HARVEST TECHNOLOGY BY BALACHANDRAN
POST HARVEST TECHNOLOGY BY BALACHANDRANPOST HARVEST TECHNOLOGY BY BALACHANDRAN
POST HARVEST TECHNOLOGY BY BALACHANDRAN
 
Tubifex worm as live feed in Aquaculture
Tubifex worm as live feed in AquacultureTubifex worm as live feed in Aquaculture
Tubifex worm as live feed in Aquaculture
 
Biofloc information
Biofloc informationBiofloc information
Biofloc information
 
Biofloc Technology
Biofloc TechnologyBiofloc Technology
Biofloc Technology
 
Shrimp Culture: Culture of Tiger Shrimp (Penaeus monodon)
Shrimp Culture: Culture of Tiger Shrimp (Penaeus monodon)Shrimp Culture: Culture of Tiger Shrimp (Penaeus monodon)
Shrimp Culture: Culture of Tiger Shrimp (Penaeus monodon)
 
Clinical Case Study PPT
Clinical Case Study PPTClinical Case Study PPT
Clinical Case Study PPT
 
SHRIMP HEALTH MANAGEMENT
SHRIMP HEALTH MANAGEMENTSHRIMP HEALTH MANAGEMENT
SHRIMP HEALTH MANAGEMENT
 
Fish for all: role of biotechnology in improving nutrition
Fish for all: role of biotechnology in improving nutritionFish for all: role of biotechnology in improving nutrition
Fish for all: role of biotechnology in improving nutrition
 
Types of coral reefs and its distribution
Types of coral reefs and its distributionTypes of coral reefs and its distribution
Types of coral reefs and its distribution
 

Viewers also liked

Dsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in ScalaDsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in Scala
Ugo Matrangolo
 
Handling Changes to Your Server-Side Data Model
Handling Changes to Your Server-Side Data ModelHandling Changes to Your Server-Side Data Model
Handling Changes to Your Server-Side Data Model
Gilt Tech Talks
 
An Intro to Swift
An Intro to SwiftAn Intro to Swift
An Intro to Swift
Gilt Tech Talks
 
Lviv MD Day 2015 Олексій Озун "Introduction to the new Apple TV and TVos"
Lviv MD Day 2015 Олексій Озун "Introduction to the new Apple TV and TVos"Lviv MD Day 2015 Олексій Озун "Introduction to the new Apple TV and TVos"
Lviv MD Day 2015 Олексій Озун "Introduction to the new Apple TV and TVos"
Lviv Startup Club
 
Introduction to tvOS app Development !
Introduction to tvOS app Development !Introduction to tvOS app Development !
Introduction to tvOS app Development !
Snehal Patil
 
The new Apple TV and the tvOS
The new Apple TV and the tvOSThe new Apple TV and the tvOS
The new Apple TV and the tvOS
Mugunth Kumar
 
tvOS
tvOStvOS
Building Apps for Apple TV
Building Apps for Apple TVBuilding Apps for Apple TV
Building Apps for Apple TV
davidolesch
 
Scaling micro services at gilt
Scaling micro services at giltScaling micro services at gilt
Scaling micro services at gilt
Adrian Trenaman
 
AbemaTV on tvOS
AbemaTV on tvOSAbemaTV on tvOS
AbemaTV on tvOS
Yuji Hato
 
Zuul @ Netflix SpringOne Platform
Zuul @ Netflix SpringOne PlatformZuul @ Netflix SpringOne Platform
Zuul @ Netflix SpringOne Platform
Mikey Cohen - Hiring Amazing Engineers
 

Viewers also liked (11)

Dsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in ScalaDsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in Scala
 
Handling Changes to Your Server-Side Data Model
Handling Changes to Your Server-Side Data ModelHandling Changes to Your Server-Side Data Model
Handling Changes to Your Server-Side Data Model
 
An Intro to Swift
An Intro to SwiftAn Intro to Swift
An Intro to Swift
 
Lviv MD Day 2015 Олексій Озун "Introduction to the new Apple TV and TVos"
Lviv MD Day 2015 Олексій Озун "Introduction to the new Apple TV and TVos"Lviv MD Day 2015 Олексій Озун "Introduction to the new Apple TV and TVos"
Lviv MD Day 2015 Олексій Озун "Introduction to the new Apple TV and TVos"
 
Introduction to tvOS app Development !
Introduction to tvOS app Development !Introduction to tvOS app Development !
Introduction to tvOS app Development !
 
The new Apple TV and the tvOS
The new Apple TV and the tvOSThe new Apple TV and the tvOS
The new Apple TV and the tvOS
 
tvOS
tvOStvOS
tvOS
 
Building Apps for Apple TV
Building Apps for Apple TVBuilding Apps for Apple TV
Building Apps for Apple TV
 
Scaling micro services at gilt
Scaling micro services at giltScaling micro services at gilt
Scaling micro services at gilt
 
AbemaTV on tvOS
AbemaTV on tvOSAbemaTV on tvOS
AbemaTV on tvOS
 
Zuul @ Netflix SpringOne Platform
Zuul @ Netflix SpringOne PlatformZuul @ Netflix SpringOne Platform
Zuul @ Netflix SpringOne Platform
 

Similar to tvOS, The Focus Engine, and Swift

Session 16 - Designing universal interface which used for iPad and iPhone
Session 16  -  Designing universal interface which used for iPad and iPhoneSession 16  -  Designing universal interface which used for iPad and iPhone
Session 16 - Designing universal interface which used for iPad and iPhone
Vu Tran Lam
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 application
Vu Tran Lam
 
tvOS: An Introduction for iOS Developers
tvOS: An Introduction for iOS DeveloperstvOS: An Introduction for iOS Developers
tvOS: An Introduction for iOS Developers
Eric Hyche
 
iOS Programming 101
iOS Programming 101iOS Programming 101
iOS Programming 101
rwenderlich
 
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Derek Lee Boire
 
"WebView, the fifth element" por @fernando_cejas
"WebView, the fifth element" por @fernando_cejas"WebView, the fifth element" por @fernando_cejas
"WebView, the fifth element" por @fernando_cejas
webcat
 
Webview: The fifth element
Webview: The fifth elementWebview: The fifth element
Webview: The fifth element
Fernando Cejas
 
Top 4 Cross Platform tools for Mobile App Development
Top 4 Cross Platform tools for Mobile App DevelopmentTop 4 Cross Platform tools for Mobile App Development
Top 4 Cross Platform tools for Mobile App Development
techugo
 
Building your first iOS app using Xamarin
Building your first iOS app using XamarinBuilding your first iOS app using Xamarin
Building your first iOS app using Xamarin
Gill Cleeren
 
Cross Platform Mobile Application Architecture
Cross Platform Mobile Application ArchitectureCross Platform Mobile Application Architecture
Cross Platform Mobile Application Architecture
Derrick Bowen
 
Building a better User Experience for Windows Phone Users
Building a better User Experience for Windows Phone UsersBuilding a better User Experience for Windows Phone Users
Building a better User Experience for Windows Phone Users
Sandra González
 
Bringing Swift into your Objective-C Projects
Bringing Swift into your Objective-C ProjectsBringing Swift into your Objective-C Projects
Bringing Swift into your Objective-C Projects
René Cacheaux
 
[iPlayground] 從 0 到 1 的距離,我與 tvOS 的邂逅
[iPlayground] 從 0 到 1 的距離,我與 tvOS 的邂逅[iPlayground] 從 0 到 1 的距離,我與 tvOS 的邂逅
[iPlayground] 從 0 到 1 的距離,我與 tvOS 的邂逅
Jia-Jyun Hsu
 
Animation in iOS
Animation in iOSAnimation in iOS
Animation in iOS
Alexis Goldstein
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
Julia Vi
 
Learning C# iPad Programming
Learning C# iPad ProgrammingLearning C# iPad Programming
Learning C# iPad Programming
Rich Helton
 
Getting started with Xamarin forms
Getting started with Xamarin formsGetting started with Xamarin forms
Getting started with Xamarin forms
SolTech, Inc.
 
J query mobile tech talk
J query mobile tech talkJ query mobile tech talk
J query mobile tech talk
woliverj
 
Create great UIs for budget phones
Create great UIs for budget phonesCreate great UIs for budget phones
Create great UIs for budget phones
Microsoft Mobile Developer
 
Why Do Mobile Projects Fail?
Why Do Mobile Projects Fail?Why Do Mobile Projects Fail?
Why Do Mobile Projects Fail?
Indiginox
 

Similar to tvOS, The Focus Engine, and Swift (20)

Session 16 - Designing universal interface which used for iPad and iPhone
Session 16  -  Designing universal interface which used for iPad and iPhoneSession 16  -  Designing universal interface which used for iPad and iPhone
Session 16 - Designing universal interface which used for iPad and iPhone
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 application
 
tvOS: An Introduction for iOS Developers
tvOS: An Introduction for iOS DeveloperstvOS: An Introduction for iOS Developers
tvOS: An Introduction for iOS Developers
 
iOS Programming 101
iOS Programming 101iOS Programming 101
iOS Programming 101
 
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
 
"WebView, the fifth element" por @fernando_cejas
"WebView, the fifth element" por @fernando_cejas"WebView, the fifth element" por @fernando_cejas
"WebView, the fifth element" por @fernando_cejas
 
Webview: The fifth element
Webview: The fifth elementWebview: The fifth element
Webview: The fifth element
 
Top 4 Cross Platform tools for Mobile App Development
Top 4 Cross Platform tools for Mobile App DevelopmentTop 4 Cross Platform tools for Mobile App Development
Top 4 Cross Platform tools for Mobile App Development
 
Building your first iOS app using Xamarin
Building your first iOS app using XamarinBuilding your first iOS app using Xamarin
Building your first iOS app using Xamarin
 
Cross Platform Mobile Application Architecture
Cross Platform Mobile Application ArchitectureCross Platform Mobile Application Architecture
Cross Platform Mobile Application Architecture
 
Building a better User Experience for Windows Phone Users
Building a better User Experience for Windows Phone UsersBuilding a better User Experience for Windows Phone Users
Building a better User Experience for Windows Phone Users
 
Bringing Swift into your Objective-C Projects
Bringing Swift into your Objective-C ProjectsBringing Swift into your Objective-C Projects
Bringing Swift into your Objective-C Projects
 
[iPlayground] 從 0 到 1 的距離,我與 tvOS 的邂逅
[iPlayground] 從 0 到 1 的距離,我與 tvOS 的邂逅[iPlayground] 從 0 到 1 的距離,我與 tvOS 的邂逅
[iPlayground] 從 0 到 1 的距離,我與 tvOS 的邂逅
 
Animation in iOS
Animation in iOSAnimation in iOS
Animation in iOS
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
 
Learning C# iPad Programming
Learning C# iPad ProgrammingLearning C# iPad Programming
Learning C# iPad Programming
 
Getting started with Xamarin forms
Getting started with Xamarin formsGetting started with Xamarin forms
Getting started with Xamarin forms
 
J query mobile tech talk
J query mobile tech talkJ query mobile tech talk
J query mobile tech talk
 
Create great UIs for budget phones
Create great UIs for budget phonesCreate great UIs for budget phones
Create great UIs for budget phones
 
Why Do Mobile Projects Fail?
Why Do Mobile Projects Fail?Why Do Mobile Projects Fail?
Why Do Mobile Projects Fail?
 

Recently uploaded

20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 

Recently uploaded (20)

20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 

tvOS, The Focus Engine, and Swift

  • 1. Evan Maloney Distinguished Engineer, Gilt Groupe tvOS, the Focus Engine & Swift Discoveries from building “Gilt on TV”
  • 3. tvOS vs. iOS: Similarities • Most of tvOS is a direct subset of iOS • Familiarity with UIKit will serve you well with tvOS • But, some of the things you may expect won’t be there • No web views • Certain frameworks like MultipeerConnectivity aren’t available • Several UIControls (pickers, steppers, sliders, etc.) • Can use Interface Builder (or not), Swift or Objective-C tvOS tvOS vs. iOS
  • 4. tvOS vs. iOS: Differences • User interaction is indirect touch • Unlike an iPhone or iPad, the user doesn’t directly manipulate the UI — uses indirect touch like a trackpad • Directionality is reversed from iOS • Relies on the Focus Engine for determining UI state • Only on tvOS — adds extensions to UIViewController, UIView, UITableView, UICollectionView, etc. tvOS tvOS vs. iOS
  • 5. Focus Engine Philosophy • The Focus Engine is intended to be a black box • You provide inputs that determine the initially focused view • You define where the user can go • Provide some visual indication of focusability • Provide an animation or visual state change upon becoming focused (often handled by the tvOS SDK) • Once your view controller is onscreen and the initial view has become focused, the user should be in control of all state changes • It is considered rude to forcibly change focus on the user tvOS The Focus Engine
  • 6. What is “Focus”? • A focusable view is one that the user can select with the touch remote • Being focusable implies that the user can perform an action on the view • Focusable views are often “pressable,” like UIButtons • A focused view renders itself to stand out from the others onscreen, usually with one or more of the following attributes: • A larger size • A drop shadow • A highlight color or border tvOS Focus
  • 7. How does the Focus Engine work? • When the view hierarchy changes, the Focus Engine creates a map of the visible focusable views • If the user navigates in a given direction, the Focus Engine looks for a focusable view in that direction, taking into account each candidate view’s focus frame size & relative position • A candidate for receiving next focus is selected • If the candidate is a table or collection cell, the relevant delegate is given an opportunity to reject focus and another candidate may be selected tvOS The Focus Engine
  • 8. tvOS The Focus Engine Gilt on TV 1.0 — Women’s Store
  • 9. tvOS The Focus Engine Focus Frames
  • 10. How does a view become “Focusable”? • By default, the following views are focusable: • UIControls • Table cells and collection cells • Can be overridden by UICollectionViewDelegate • UIViews that are not otherwise focusable can be made so by overriding canBecomeFocused() • The focused property of a UIView indicates whether the view is currently in focus tvOS Focus
  • 11. How does a view become “Focused”? • When a view controller is displayed, the focus engine asks for the preferredFocusedView from the relevant views and view controllers to determine which view gets initial focus • From there, the user controls focus using the remote • When the user swipes in a given direction, the Focus Engine selects an appropriate focusable view to get next focus • Developers can use the UIFocusUpdateContext to coordinate animations when views go into and out of focus tvOS Focus
  • 12. tvOS The Focus Engine Gilt on TV 1.0 — Men’s Store (scrolled)
  • 13. tvOS The Focus Engine Focus Frames
  • 14. tvOS The Focus Engine Changing Focus — Unambiguous Move
  • 15. tvOS The Focus Engine Ambiguous Move — Focus Engine Chooses
  • 16. tvOS The Focus Engine Sale View
  • 17. tvOS The Focus Engine Focus Frames
  • 18. tvOS The Focus Engine Navigating to “Buy Now” — A Near Miss
  • 19. The Dilemma tvOS Focus Guides How could you solve it? You can’t assume the Focus Engine “sees” focusable views that aren’t in the direct path of the swipe direction tvOS solution Allow a UIView to report to a focus frame that’s larger than the view’s native frame 1. Call parentView.addLayoutGuide(UIFocusGuide) 2. Set the focus guide’s preferredFocusedView 3. Add Auto Layout constraints using the focus guide as you would any UIView
  • 20. tvOS Focus Guides A focus guide defines a screen rectangle
  • 21. tvOS Focus Guides Focus is forwarded to the preferredFocusedView
  • 22. tvOS Focus Guides Allowing a small button to respond to a large frame
  • 23. Handling scrolling content • You will not be able to present scrolling content in the same way you do in iOS • User can only scroll by navigating to something focusable within a scroll view • The Focus Engine only pays attention to focusable non-hidden views with non-zero alphas that have at least one pixel within the screen bounds • Focusable views and cells that are offscreen won’t be visible to the Focus Engine, so the user can’t navigate to them tvOS The Focus Engine
  • 26. Other challenges for tvOS developers • Apparently a lot of people rely on web views for mission-critical screens within their apps — they will be forced to rethink • Restrictions on App Store binaries: • Applications need to be submitted as Bitcode binaries • This includes embedded frameworks, which makes many third-party closed-source frameworks unusable in tvOS • On-device testing — Very few people have development devices, and simulator testing may not reveal all problems tvOS tvOS Development
  • 27. Fun things about tvOS development • Some of the iOS pain points don’t exist on tvOS • Apple TVs will often be used to stream video — unlike with mobile devices, tvOS developers can assume the presence of low-latency, always-on, high-bandwidth networks • Don’t need to think about screen rotation or size class changes • Only need to develop for a single screen resolution — for now tvOS tvOS Development
  • 28. A few words about Swift and finally…
  • 29. Swift — Pain Points • The language is still changing, so major releases of Xcode often require a bit of code rewriting • Usually minimal, and the language is improving as a result • Developer tooling still needs work • Debugger sometimes refuses to cough up variable values • Compiler errors can be vague or misleading • Compiler stability is sometimes an issue • Heavy use of Swift frameworks sometimes doesn’t play nicely with “whole module optimization” • Binaries may not be compatible across compiler versions tvOS Swift
  • 30. Swift — Advantages • Swift may not be mature, but it is ready for prime-time • Swift absolutely fulfills the promise of more efficient development • An entire class of errors that used to require runtime debugging is now caught by the compiler • Building a stable app takes much less work than Objective-C • I probably spent about ¼ the time debugging as I would have had to do in ObjC • Coding in Swift is an absolute pleasure tvOS Swift
  • 31. Swift — The Verdict tvOS Swift Do it! You know you’ll “go Swift” eventually… …and the longer you wait, the more you’ll be kicking yourself for not having done it sooner once you finally do!
  • 32. Evan Maloney Distinguished Engineer, Gilt Groupe A parting gift for you https://github.com/emaloney/CleanroomLogger CleanroomLogger — A pure Swift logging engine Simple, lightweight & performant Code goodies!