LoginSignup
59
60

More than 5 years have passed since last update.

iOS 9からForce Touch(3D Touch) API解禁(iOS 9.1ではさらにリッチに)

Last updated at Posted at 2015-09-10

本記事は、3D Touchのドキュメント未公開時に、API探しながら書きましたが、その後公開されました。
Adopting 3D Touch on iPhone: 3D Touch APIs


Pre Release用のUITouchのドキュメントに、Force Touchについての記載がありました。
(普通のUITouch Class Reference にはない)

UIForceTouchCapability - UITraitCollection Class Referenceにもけっこう記載があります。

3D Touch and Trait Collections
Starting in iOS 9, you can use this class to check whether the device on which your app is running supports 3D Touch. Read the value of the forceTouchCapability property on the trait collection for any object in your app with a trait environment.

forceTouchCapabilityにてチェックするようで、iPhone 6sシミュレーターでもAvailableじゃ無かったです(´・︵・`)

僕がチェックしていた限りは、これまでAPIとしては公開されていなくて、今朝のGM版リリースのタイミングで公開された気がします。
とにかくこれで、Force Touch機能を自分のアプリでも使えるようになりますね。
シミュレーターではForce Touchを再現出来るメニューが見当たらず、iPhone 6sリリース(25日)・シミュレーターの対応待ちという感じでしょうか(´-ω-`)
→ Apple Watchと同様、メニュー自体はありました。

ViewControllerPreviews: Using the UIViewController previewing APIsのサンプルなどで使われています。

それぞれの詳しい内容はドキュメント見た方が良いと思いますが、目diffかけてみましたʕ ·ᴥ·ʔ

iOS 9で増えるもの

  • Getting Touch Attributes
    • force
    • maximumPossibleForce
  • Constants
    • UIForceTouchCapability
    • UITouchType
    • UITouchProperties

iOS 9.1で増えるもの

iPad Proのスタイラス周りのAPIに関係しそうなものが多い印象( ´・‿・`)

  • Getting the Location of a Touch
    • preciseLocationInView:
    • precisePreviousLocationInView:
  • Getting Touch Attributes
    • altitudeAngle
    • azimuthAngleInView:
    • azimuthUnitVectorInView:
    • estimatedProperties
    • updatedProperties
    • estimationUpdateIndex

関連

59
60
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
59
60