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

watchOS3の新機能 / watchos3

watchOS3の新機能 / watchos3

Katsuya Kato

December 08, 2016
Tweet

More Decks by Katsuya Kato

Other Decks in Technology

Transcript

  1. watchOS 3ͷ৽ػೳ Katsuya Kato 2016/12/8

  2. ࣗݾ঺հ • ໊લ • Ճ౻উ໵ • ݴޠ • Swift/Objective-C/Java •

    ૊ࠐ։ൃ΋΍͍ͬͯͨͷͰCͱ͔Ξηϯϒϥͱ͔ Verilogʢϋʔυ΢ΣΞهड़ݴޠʣͱ͔΋ᅂΉ
  3. ͸͡Ίʹ • ࠓ೔͸watch OS3ͷ৽ػೳʹ͍ͭͯ࿩͠·͢

  4. watchOS 3 ͷ৽ػೳ

  5. σδλϧΫϥ΢ϯͷঢ়ଶΛ औΔ͜ͱ͕Ͱ͖ΔΑ͏ʹ ͳͬͨʂ

  6. σδλϧΫϥ΢ϯͬͯʁ ͜Ε

  7. WKCrownSequencer / WKCrownDelegate • ճసͷྔʢԿճస͔ʣͱճసͷ଎౓ΛऔΔ͜ͱ ͕Ͱ͖Δ • ࠓ·Ͱ͸εΫϩʔϧͱϐοΧʔͰ͔͠ར༻Ͱ͖ ͳ͔͕ͬͨɺΦϦδφϧͷUIʹ࢖͑ͦ͏ʁ

  8. WKCrownSequencer / WKCrownDelegate crownSequencer.delegate = self crownSequencer.focus() • WKInterfaceControllerͷϓϩύςΟʹcrownSequencer͕͋Δ ͷͰdelegateΛηοτɻfucusϝιουͰσʔλऔಘ։࢝

    extension InterfaceController: WKCrownDelegate { public func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) { print("Delta:¥(rotationalDelta)") if let crownSequencer = crownSequencer { print("PerSecond:¥(crownSequencer.rotationsPerSecond)") } } } • ճసͤͨ͞Βdelegateϝιου͕ݺ͹ΕΔ
  9. δΣενϟʔΛ औಘͰ͖ΔΑ͏ʹͳͬͨʂ

  10. δΣενϟʔΛऔಘͰ͖ΔΑ ͏ʹͳͬͨʂ • UIGestureRecognizerͷWatchKit൛Ͱ͋Δ WKGestureRecognizer͕௥Ճ͞Εͨ • WKTapGestureRecognizer • WKLongPressGestureRecognizer •

    WKPanGestureRecognizer • WKSwipeGestureRecognizer
  11. WKTapGestureRecognizer/ WKLongPressGestureRecognizer @IBAction func handleTapGesture(gestureRecognizer : WKTapGestureRecognizer) { print("x:(¥(gestureRecognizer.locationInObject().x)") print("y:(¥(gestureRecognizer.locationInObject().y)")

    } @IBAction func handleLongPressGesture(gestureRecognizer : WKLongPressGestureRecognizer) { print("x:(¥(gestureRecognizer.locationInObject().x)") print("y:(¥(gestureRecognizer.locationInObject().y)") }
  12. WKSwipeGestureRecognizer @IBAction func handleSwipeGesture(gestureRecognizer : WKSwipeGestureRecognizer) { switch gestureRecognizer.direction {

    case WKSwipeGestureRecognizerDirection.right: label.setText("Swipe Right") case WKSwipeGestureRecognizerDirection.left: label.setText("Swipe Left") case WKSwipeGestureRecognizerDirection.down: label.setText("Swipe Down") case WKSwipeGestureRecognizerDirection.up: label.setText("Swipe Up") default: break } }
  13. WKPanGestureRecognizer @IBAction func handlePanGesture(gestureRecognizer : WKPanGestureRecognizer) { print("x:¥(gestureRecognizer.translationInObject().x)" print("y:¥(gestureRecognizer.translationInObject().y)") }

  14. δϟΠϩείʔϓͷ஋͕ औΕΔΑ͏ʹͳͬͨʂ

  15. CMDeviceMotion • Ճ଎౓ɺδϟΠϩɺ࢟੎ΛऔΔ͜ͱ͕Ͱ͖Δ https://developer.apple.com/library/content/documentation/EventHandling/Conceptual/EventHand lingiPhoneOS/motion_event_basics/motion_event_basics.html#//apple_ref/doc/uid/TP40009541- CH6-SW14

  16. CMDeviceMotion let handler: CMDeviceMotionHandler = {(motion: CMDeviceMotion?, error: Error?) ->

    Void in if let motion = motion { // Ճ଎౓ηϯα print(motion.gravity.x) print(motion.gravity.y) // δϟΠϩείʔϓ print(motion.rotationRate.x) print(motion.rotationRate.y) // ࢟੎ print(motion.attitude.roll) print(motion.attitude.yaw) print(motion.attitude.pitch) } } • ·ͣ͸ϋϯυϥΛ༻ҙ
  17. CMDeviceMotion let motionManager = CMMotionManager() if motionManager.isDeviceMotionAvailable { motionManager.startDeviceMotionUpdates( to:

    OperationQueue.current!, withHandler: handler) } • CMMotionManagerͷstartDeviceMotionUpdates ϝιουʹϋϯυϥΛࢦఆͯ͠ܭଌ։࢝
  18. όοΫάϥ΢ϯυॲཧ͕ Ͱ͖ΔΑ͏ʹͳͬͨ

  19. όοΫάϥ΢ϯυॲཧ • Background App Refresh • Background Snapshot Refresh •

    Կ෼ޙʹ࣮ߦ͢Δ͔࣌ؒΛࢦఆͯ͠όοΫάϥ΢ϯ υͰॲཧ/εφοϓγϣοτͷߋ৽͕Ͱ͖Δ
  20. ੍ݶ͸ͳ͍ͷ͔ʁ • ࣌ؒΛࢦఆͯ͠΋ඞͣͦͷ࣌ؒʹ࣮ߦ͞ΕΔͱ ͸ݶΒͳ͍ • 1ΞϓϦʹ෇͖1࣌ؒʹ1ճ • ঢ়گʹΑͬͯ͸͞Βʹ஗Ԇ͢Δ͜ͱ΋͋Δͱ υΩϡϝϯτʹ͸ॻ͔Ε͍ͯΔ

  21. όοΫάϥ΢ϯυॲཧ • AppleWatch͕όοΫάϥϯυͰ΋ iPhoneͱ௨৴Ͱ͖ΔΑ͏ʹͳͬͨ • watchOS2·Ͱ͸ • AppleWatch→iPhoneͷ৔߹͸ड͚ΔଆͷiPhone͕ όοΫάϥ΢ϯυͰ΋OK •

    iPhone→ AppleWatch͸ड͚ΔଆͷAppleWatch͕ ϑΥΞάϥ΢ϯυͰ͋Δඞཁ͕͋ͬͨ • iPhoneͰΞϓϦΛૢ࡞ͨ͠ͱ͖ʹWatchʹσʔλΛ౤ ͓͍͛ͯͯԿ͔͠ΒͷॲཧΛ࣮ߦͤ͞Δ͜ͱ͕Ͱ͖Δ Α͏ʹͳͬͨ
  22. SpriteKit/SceneKit͕ ࢖͑ΔΑ͏ʹͳͬͨʂ

  23. SpriteKit/SceneKitͱ͸ʁ • SpriteKit/SceneKitͱ͸2Dɺ3DήʔϜΛ ࡞ΔͨΊͷϑϨʔϜϫʔΫ • Cocos2DΈ͍ͨͳ΋ͷ • AppleWatchͰήʔϜʁʁ AppleWatchͷղ૾౓ͬͯʁʁ •

    38mm 272px x 340px • 42mm 312px x 390px
  24. SpriteKitͱTapGestureΛ ࢖ͬͨήʔϜΛ࡞ͬͯΈͨ • FlappyBird΋Ͳ͖ • SpriteKitͱWKTapGestureRecognizerͰ 2DԣεΫϩʔϧΞΫγϣϯ

  25. SpriteKitͱTapGestureΛ࢖ͬ ͨήʔϜΛ࡞ͬͯΈͨ

  26. ·ͱΊ • watchOS3Ͱ͸ • औಘͰ͖ΔσόΠεɾηϯαʔͷ৘ใ͕૿͑ͨ • όοΫάϥ΢ϯυॲཧ͕Ͱ͖ΔΑ͏ʹͳͬͨ • SpriteKit/SceneKitͰήʔϜٴͼϦονͳදݱ͕Ͱ͖ΔΑ͏ʹͳͬͨ •

    Audio/iCloud/GameCenterपΓ΋ڧԽ͞Εͨ • Appleͱͯ͠͸ήʔϜΛ࡞ͬͯ΄͍͠ʁʁ • Ͱ͖Δ͜ͱ͸૿͑ͨͷͰ͋ͱ͸ΞΠσΞ࣍ୈ • Ͱ΋γΣΞ͕૿͑ͳ͍͜ͱʹ͸ɾɾɾ • ΤϯδχΞ͕Ͱ͖Δ͜ͱ͸AppleWatch͕ ཉ͘͠ͳΔັྗతͳΞϓϦΛ࡞Δ͜ͱ
  27. ιʔείʔυ • WatchͰಈ͘FlappyBird΋Ͳ͖ɿWatchDeBird https://goo.gl/8n6qIH • WKCrownSample https://goo.gl/iZr4pz • CMDeviceMotionSample https://goo.gl/SbWevj

    • KGestureRecognizerSample https://goo.gl/8U5FiW