Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Apple TV - tvOS入門 -

Yuji Hato
September 17, 2017

Apple TV - tvOS入門 -

Apple TV Introduction to tvOS

Yuji Hato

September 17, 2017
Tweet

More Decks by Yuji Hato

Other Decks in Technology

Transcript

  1. ・64-bit A8 processor ・32GB or 64GB of storage ・2GB of

    RAM ・10/100Mbps Ethernet ・WiFi 802.11a/b/g/n/ac ・1080p resolution ・HDMI 1.4 Apple TV 4th generation ・A10X Fusion ・32GB or 64GB of storage ・3GB of RAM ・Gigabit Ethernet ・Wi-Fi with MIMO 802.11ac ・2160p resolution ・HDMI 2.0 4K
  2. 32GB 15,800円 64GB 20,800円 ※2016/09に値下げ ・32GB 18,400円 →15,800円(2,600円値下げ) ・64GB 24,800円

    →20,800円(4,000円値下げ) Apple TV (tvOS) 4th generation 4K 32GB 19,800円 64GB 21,800円
  3. Limited Local Storage 4FSWJDF 0OMJOF-PDBM 1FSTJTUFOU 5FNQPSBSZ MJNJU J$MPVE,FZ7BMVF 4UPSF

    ,74 0OMJOF 1FSTJTUFOU .#NBY $MPVE,JU 0OMJOF 1FSTJTUFOU  6TFS%FGBVMUT -PDBM 1FSTJTUFOU ,#NBY ,FZDIBJO -PDBM 1FSTJTUFOU  $BDIF%JSFDUPSZ -PDBM 5FNQPSBSZ .BZCFQVSHFE 5FNQPSBSZ%JSFDUPSZ -PDBM 5FNQPSBSZ .BZCFQVSHFE
  4. Limited Local Storage 4FSWJDF 0OMJOF-PDBM 1FSTJTUFOU 5FNQPSBSZ MJNJU J$MPVE,FZ7BMVF 4UPSF

    ,74 0OMJOF 1FSTJTUFOU .#NBY $MPVE,JU 0OMJOF 1FSTJTUFOU  6TFS%FGBVMUT -PDBM 1FSTJTUFOU ,#NBY ,FZDIBJO -PDBM 1FSTJTUFOU  $BDIF%JSFDUPSZ -PDBM 5FNQPSBSZ .BZCFQVSHFE 5FNQPSBSZ%JSFDUPSZ -PDBM 5FNQPSBSZ .BZCFQVSHFE
  5. Limited Local Storage 4FSWJDF 0OMJOF-PDBM 1FSTJTUFOU 5FNQPSBSZ MJNJU J$MPVE,FZ7BMVF 4UPSF

    ,74 0OMJOF 1FSTJTUFOU .#NBY $MPVE,JU 0OMJOF 1FSTJTUFOU  6TFS%FGBVMUT -PDBM 1FSTJTUFOU ,#NBY ,FZDIBJO -PDBM 1FSTJTUFOU  $BDIF%JSFDUPSZ -PDBM 5FNQPSBSZ .BZCFQVSHFE 5FNQPSBSZ%JSFDUPSZ -PDBM 5FNQPSBSZ .BZCFQVSHFE
  6. Limited Local Storage 4FSWJDF 0OMJOF-PDBM 1FSTJTUFOU 5FNQPSBSZ MJNJU J$MPVE,FZ7BMVF 4UPSF

    ,74 0OMJOF 1FSTJTUFOU .#NBY $MPVE,JU 0OMJOF 1FSTJTUFOU  6TFS%FGBVMUT -PDBM 1FSTJTUFOU ,#NBY ,FZDIBJO -PDBM 1FSTJTUFOU  $BDIF%JSFDUPSZ -PDBM 5FNQPSBSZ .BZCFQVSHFE 5FNQPSBSZ%JSFDUPSZ -PDBM 5FNQPSBSZ .BZCFQVSHFE
  7. Focus public var preferredFocusEnvironments: [UIFocusEnvironment] { get } public func

    shouldUpdateFocus(in context: UIFocusUpdateContext) -> Bool public func setNeedsFocusUpdate() public func updateFocusIfNeeded() public func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) @available(tvOS 11.0, *) optional public func soundIdentifierForFocusUpdate(in context: UIFocusUpdateContext) -> UIFocusSoundIdentifier? UIFocusEnvironmentϓϩτίϧ
  8. Focus public var preferredFocusEnvironments: [UIFocusEnvironment] { get } public func

    shouldUpdateFocus(in context: UIFocusUpdateContext) -> Bool public func setNeedsFocusUpdate() public func updateFocusIfNeeded() public func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) @available(tvOS 11.0, *) optional public func soundIdentifierForFocusUpdate(in context: UIFocusUpdateContext) -> UIFocusSoundIdentifier? UIFocusEnvironmentϓϩτίϧ
  9. Focus public var preferredFocusEnvironments: [UIFocusEnvironment] { get } public func

    shouldUpdateFocus(in context: UIFocusUpdateContext) -> Bool public func setNeedsFocusUpdate() public func updateFocusIfNeeded() public func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) @available(tvOS 11.0, *) optional public func soundIdentifierForFocusUpdate(in context: UIFocusUpdateContext) -> UIFocusSoundIdentifier? UIFocusEnvironmentϓϩτίϧ
  10. Focus public var preferredFocusEnvironments: [UIFocusEnvironment] { get } public func

    shouldUpdateFocus(in context: UIFocusUpdateContext) -> Bool public func setNeedsFocusUpdate() public func updateFocusIfNeeded() public func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) @available(tvOS 11.0, *) optional public func soundIdentifierForFocusUpdate(in context: UIFocusUpdateContext) -> UIFocusSoundIdentifier? UIFocusEnvironmentϓϩτίϧ
  11. Focus public var preferredFocusEnvironments: [UIFocusEnvironment] { get } public func

    shouldUpdateFocus(in context: UIFocusUpdateContext) -> Bool public func setNeedsFocusUpdate() public func updateFocusIfNeeded() public func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) @available(tvOS 11.0, *) optional public func soundIdentifierForFocusUpdate(in context: UIFocusUpdateContext) -> UIFocusSoundIdentifier? UIFocusEnvironmentϓϩτίϧ
  12. Focus public var preferredFocusEnvironments: [UIFocusEnvironment] { get } public func

    shouldUpdateFocus(in context: UIFocusUpdateContext) -> Bool public func setNeedsFocusUpdate() public func updateFocusIfNeeded() public func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) @available(tvOS 11.0, *) optional public func soundIdentifierForFocusUpdate(in context: UIFocusUpdateContext) -> UIFocusSoundIdentifier? UIFocusEnvironmentϓϩτίϧ
  13. Focus @available(tvOS 10.0, *) public protocol UIFocusItem : UIFocusEnvironment {

    public var canBecomeFocused: Bool { get } } UIFocusItemϓϩτίϧ
  14. Focus • UIButton • UITextField • UITableView • UICollectionView •

    UITextView • UISegmentedControl • UISearchBar • etc..
  15. Focus class CustomLabel: UILabel { override init(frame: CGRect) { super.init(frame:

    frame) isUserInteractionEnabled = true } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) isUserInteractionEnabled = true } override var canBecomeFocused: Bool { return true } } } } UILabel for Focus
  16. Focus override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {

    super.didUpdateFocus(in: context, with: coordinator) // Focus if context.nextFocusedView == self { coordinator.addCoordinatedFocusingAnimations({ [weak self] context in self?.transform = CGAffineTransform(scaleX: 1.4, y: 1.4) }, completion: nil) } // UnFocus if context.previouslyFocusedView == self { coordinator.addCoordinatedUnfocusingAnimations({ [weak self] context in self?.transform = CGAffineTransform.identity }, completion: nil) } } UILabel for Focus
  17. Focus override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {

    super.didUpdateFocus(in: context, with: coordinator) // Focus if context.nextFocusedView == self { coordinator.addCoordinatedFocusingAnimations({ [weak self] context in self?.transform = CGAffineTransform(scaleX: 1.4, y: 1.4) }, completion: nil) } // UnFocus if context.previouslyFocusedView == self { coordinator.addCoordinatedUnfocusingAnimations({ [weak self] context in self?.transform = CGAffineTransform.identity }, completion: nil) } } UILabel for Focus
  18. Focus override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {

    super.didUpdateFocus(in: context, with: coordinator) // Focus if context.nextFocusedView == self { coordinator.addCoordinatedFocusingAnimations({ [weak self] context in self?.transform = CGAffineTransform(scaleX: 1.4, y: 1.4) }, completion: nil) } // UnFocus if context.previouslyFocusedView == self { coordinator.addCoordinatedUnfocusingAnimations({ [weak self] context in self?.transform = CGAffineTransform.identity }, completion: nil) } } UILabel for Focus
  19. Focus UITableViewDelegate for Focus @available(tvOS 9.0, *) optional public func

    tableView(_ tableView: UITableView, canFocusRowAt indexPath: IndexPath) -> Bool @available(tvOS 9.0, *) optional public func tableView(_ tableView: UITableView, shouldUpdateFocusIn context: UITableViewFocusUpdateContext) -> Bool @available(tvOS 9.0, *) optional public func tableView(_ tableView: UITableView, didUpdateFocusIn context: UITableViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) @available(tvOS 9.0, *) optional public func indexPathForPreferredFocusedView(in tableView: UITableView) -> IndexPath?
  20. Focus @available(tvOS 9.0, *) optional public func collectionView(_ collectionView: UICollectionView,

    canFocusItemAt indexPath: IndexPath) -> Bool @available(tvOS 9.0, *) optional public func collectionView(_ collectionView: UICollectionView, shouldUpdateFocusIn context: UICollectionViewFocusUpdateContext) -> Bool @available(tvOS 9.0, *) optional public func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context: UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) @available(tvOS 9.0, *) optional public func indexPathForPreferredFocusedView(in collectionView: UICollectionView) -> IndexPath? @available(tvOS 9.0, *) optional public func collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveFromItemAt originalIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -> IndexPath @available(tvOS 9.0, *) optional public func collectionView(_ collectionView: UICollectionView, targetContentOffsetForProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint UICollectionViewDelegate for Focus
  21. Focus @available(tvOS 9.0, *) open var adjustsImageWhenAncestorFocused: Bool @available(tvOS 9.0,

    *) open var focusedFrameGuide: UILayoutGuide { get } @available(tvOS 11.0, *) open var overlayContentView: UIView { get } @available(tvOS 11.0, *) open var masksFocusEffectToContents: Bool UIImageView for Focus
  22. Focus @available(tvOS 9.0, *) open var adjustsImageWhenAncestorFocused: Bool @available(tvOS 9.0,

    *) open var focusedFrameGuide: UILayoutGuide { get } @available(tvOS 11.0, *) open var overlayContentView: UIView { get } @available(tvOS 11.0, *) open var masksFocusEffectToContents: Bool UIImageView for Focus
  23. Focus UIImageView for Focus @available(tvOS 9.0, *) open var adjustsImageWhenAncestorFocused:

    Bool @available(tvOS 9.0, *) open var focusedFrameGuide: UILayoutGuide { get } @available(tvOS 11.0, *) open var overlayContentView: UIView { get } @available(tvOS 11.0, *) open var masksFocusEffectToContents: Bool
  24. Focus // UICollectionView delegate func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context:

    UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) { // Focus if let cell = context.nextFocusedView as? CostomCollectionViewCell { coordinator.addCoordinatedFocusingAnimations({ context in cell.imageView.overlayContentView.alpha = 0 }, completion: nil) } // UnFocus if let cell = context.previouslyFocusedView as? CostomCollectionViewCell { coordinator.addCoordinatedUnfocusingAnimations({ context in cell.imageView.overlayContentView.alpha = 1 }, completion: nil) } } UIImageView for Focus
  25. Focus // UICollectionView delegate func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context:

    UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) { // Focus if let cell = context.nextFocusedView as? CostomCollectionViewCell { coordinator.addCoordinatedFocusingAnimations({ context in cell.imageView.overlayContentView.alpha = 0 }, completion: nil) } // UnFocus if let cell = context.previouslyFocusedView as? CostomCollectionViewCell { coordinator.addCoordinatedUnfocusingAnimations({ context in cell.imageView.overlayContentView.alpha = 1 }, completion: nil) } } UIImageView for Focus
  26. Focus // UICollectionView delegate func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context:

    UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) { // Focus if let cell = context.nextFocusedView as? CostomCollectionViewCell { coordinator.addCoordinatedFocusingAnimations({ context in cell.imageView.overlayContentView.alpha = 0 }, completion: nil) } // UnFocus if let cell = context.previouslyFocusedView as? CostomCollectionViewCell { coordinator.addCoordinatedUnfocusingAnimations({ context in cell.imageView.overlayContentView.alpha = 1 }, completion: nil) } } UIImageView for Focus
  27. Focus Focus Update Notification extension NSNotification.Name { @available(tvOS 11.0, *)

    public static let UIFocusDidUpdate: NSNotification.Name @available(tvOS 11.0, *) public static let UIFocusMovementDidFail: NSNotification.Name } @available(tvOS 11.0, *) public let UIFocusUpdateContextKey: String @available(tvOS 11.0, *) public let UIFocusUpdateAnimationCoordinatorKey: String
  28. Focus Focus Update Notification extension NSNotification.Name { @available(tvOS 11.0, *)

    public static let UIFocusDidUpdate: NSNotification.Name @available(tvOS 11.0, *) public static let UIFocusMovementDidFail: NSNotification.Name } @available(tvOS 11.0, *) public let UIFocusUpdateContextKey: String @available(tvOS 11.0, *) public let UIFocusUpdateAnimationCoordinatorKey: String
  29. Focus Focus Update Notification extension NSNotification.Name { @available(tvOS 11.0, *)

    public static let UIFocusDidUpdate: NSNotification.Name @available(tvOS 11.0, *) public static let UIFocusMovementDidFail: NSNotification.Name } @available(tvOS 11.0, *) public let UIFocusUpdateContextKey: String @available(tvOS 11.0, *) public let UIFocusUpdateAnimationCoordinatorKey: String
  30. Focus @available(tvOS 9.0, *) open class UIFocusGuide : UILayoutGuide {

    open var isEnabled: Bool @available(tvOS 10.0, *) open var preferredFocusEnvironments: [UIFocusEnvironment]! } UIFocusGuide
  31. Focus focusGuide = UIFocusGuide() view.addLayoutGuide(focusGuide) // Anchor the top left

    of the focus guide. focusGuide.topAnchor.constraint(equalTo: button.topAnchor).isActive = true focusGuide.leftAnchor.constraint(equalTo: collectionView.leftAnchor).isActive = true // Anchor the width and height of the focus guide. focusGuide.heightAnchor.constraint(equalTo: button.heightAnchor).isActive = true focusGuide.widthAnchor.constraint(equalTo: collectionView.widthAnchor).isActive = true focusGuide.preferredFocusEnvironments = [button] UIFocusGuide
  32. Focus focusGuide = UIFocusGuide() view.addLayoutGuide(focusGuide) // Anchor the top left

    of the focus guide. focusGuide.topAnchor.constraint(equalTo: button.topAnchor).isActive = true focusGuide.leftAnchor.constraint(equalTo: collectionView.leftAnchor).isActive = true // Anchor the width and height of the focus guide. focusGuide.heightAnchor.constraint(equalTo: button.heightAnchor).isActive = true focusGuide.widthAnchor.constraint(equalTo: collectionView.widthAnchor).isActive = true focusGuide.preferredFocusEnvironments = [button] UIFocusGuide
  33. Focus focusGuide = UIFocusGuide() view.addLayoutGuide(focusGuide) // Anchor the top left

    of the focus guide. focusGuide.topAnchor.constraint(equalTo: button.topAnchor).isActive = true focusGuide.leftAnchor.constraint(equalTo: collectionView.leftAnchor).isActive = true // Anchor the width and height of the focus guide. focusGuide.heightAnchor.constraint(equalTo: button.heightAnchor).isActive = true focusGuide.widthAnchor.constraint(equalTo: collectionView.widthAnchor).isActive = true focusGuide.preferredFocusEnvironments = [button] UIFocusGuide
  34. Focus focusGuide = UIFocusGuide() view.addLayoutGuide(focusGuide) // Anchor the top left

    of the focus guide. focusGuide.topAnchor.constraint(equalTo: button.topAnchor).isActive = true focusGuide.leftAnchor.constraint(equalTo: collectionView.leftAnchor).isActive = true // Anchor the width and height of the focus guide. focusGuide.heightAnchor.constraint(equalTo: button.heightAnchor).isActive = true focusGuide.widthAnchor.constraint(equalTo: collectionView.widthAnchor).isActive = true focusGuide.preferredFocusEnvironments = [button] UIFocusGuide
  35. Focus focusGuide = UIFocusGuide() view.addLayoutGuide(focusGuide) // Anchor the top left

    of the focus guide. focusGuide.topAnchor.constraint(equalTo: button.topAnchor).isActive = true focusGuide.leftAnchor.constraint(equalTo: collectionView.leftAnchor).isActive = true // Anchor the width and height of the focus guide. focusGuide.heightAnchor.constraint(equalTo: button.heightAnchor).isActive = true focusGuide.widthAnchor.constraint(equalTo: collectionView.widthAnchor).isActive = true focusGuide.preferredFocusEnvironments = [button] UIFocusGuide
  36. Focus The result of the focus update was determined from

    the following preferred focus search: | | Starting preferred focus search: | |--> Searching <UIFocusSystem 0x60000028dc00>... | |--> Searching <UIScreen 0x6080001d3fb0>... | |--> Searching <UIWindow 0x7fb79cb02af0>... | |--> Searching <tvos_sample_for_iosdc.RootViewController 0x7fb79c904da0>... | |--> Searching <UIView Focus Update Logging
  37. Focus po UIFocusDebugger.simulateFocusUpdateRequest(from: imageView) Simulating a fake focus update request

    from <UIImageView 0x7ff3ce2106d0>... (<tvos_sample_for_iosdc.MainCollectionViewCell 0x7ff3ce20fe60> is currently focused) The following issues were found that would normally prevent this environment's request from being accepted by the focus system (these will be ignored for the purposes of this test): - ISSUE: This environment does not contain the currently focused item. Starting preferred focus search: |--> Searching <UIImageView 0x7ff3ce2106d0>... No more preferences for this environment, and there are no focusable items in this environment to prefer by default. This environment does not prefer a valid focusable item, nor any other environments. Simulated Result: Successfully updated focus to nil. UIFocusDebugger
  38. Focus po UIFocusDebugger.checkFocusability(for: label) The following issues were found that

    would prevent this item from being focusable: - ISSUE: This view has isUserInteractionEnabled set to NO. Views must allow user interaction to be focusable. UIFocusDebugger