2016-11-09 84 views

回答

6

iPhone 7擁有比iPhone 6s更精確,更靈活的Taptic引擎 - 您可以使用UIFeedbackGenerator類羣獲取iPhone 7支持的更豐富的觸覺反饋信號詞彙表,但這些API對iPhone 6s沒有影響(或其他設備)。

iPhone 6仍然具有Taptic引擎,但它不如新版引擎 - 它僅支持與3D Touch功能相關的觸覺信號。然而,可以使用那些在你的應用:

  • 建立一個標準皮克/流行UI(觸覺包括)到您的應用程序,使用已做到這一點(如表和收集意見)標準的意見,在你的故事板中設置窺視/流行音樂段落,和/或在視圖控制器中採用UIViewControllerPreviewingUIViewControllerPreviewingDelegate協議。您可以在iOS的9

  • 這樣做是爲了提供偷看/流行手勢支持 - 包括所附的觸覺反饋 - 沒有UI,或者用自己的自定義UI,使用UIPreviewInteraction類及其delegate protocol。這部分需要iOS 10.

有關PEEK /流行,3D觸摸,和一般的觸覺更多信息,請參閱WWDC16會議"A Peek at 3D Touch"和蘋果的指導Adopting 3D Touch on iPhone

9

觸覺反饋引擎已經在iPhone7被引入/ 7 +,你可以通過UIFeedbackGenerator使用它,這裏有一個例子:

let generator = UIImpactFeedbackGenerator(style: .heavy) 
generator.prepare() 

generator.impactOccurred() 

至於iPhone 6S/6S我發現那種後備,請嘗試它,如果你有設備描述的經驗:

import AudioToolbox 


AudioServicesPlaySystemSound(1519) // Actuate `Peek` feedback (weak boom) 
AudioServicesPlaySystemSound(1520) // Actuate `Pop` feedback (strong boom) 
AudioServicesPlaySystemSound(1521) // Actuate `Nope` feedback (series of three weak booms) 

我試着概括一切,我發現關於觸覺反饋的位置: http://www.mikitamanko.com/blog/2017/01/29/haptic-feedback-with-uifeedbackgenerator/