Iphone6s是否具有反馈引擎,我可以使用名为UIFeedbackGenerator
的公共API来访问它吗?iOS 10 iPhone 6S使用触觉引擎播放触觉反馈或振动
回答
iPhone 7拥有比iPhone 6s更精确,更灵活的Taptic引擎 - 您可以使用UIFeedbackGenerator
类群获取iPhone 7支持的更丰富的触觉反馈信号词汇表,但这些API对iPhone 6s没有影响(或其他设备)。
iPhone 6仍然具有Taptic引擎,但它不如新版引擎 - 它仅支持与3D Touch功能相关的触觉信号。然而,可以使用那些在你的应用:
建立一个标准皮克/流行UI(触觉包括)到您的应用程序,使用已做到这一点(如表和收集意见)标准的意见,在你的故事板中设置窥视/流行音乐段落,和/或在视图控制器中采用
UIViewControllerPreviewing
和UIViewControllerPreviewingDelegate
协议。您可以在iOS的9这样做是为了提供偷看/流行手势支持 - 包括所附的触觉反馈 - 没有UI,或者用自己的自定义UI,使用
UIPreviewInteraction
类及其delegate protocol。这部分需要iOS 10.
有关PEEK /流行,3D触摸,和一般的触觉更多信息,请参阅WWDC16会议"A Peek at 3D Touch"和苹果的指导Adopting 3D Touch on iPhone。
不,暂时引擎目前仅在iPhone 7和7+上可用。
此时,只有在iPhone 7和iPhone 7 Plus中发现的新Taptic Engine支持这些API。其他设备默默地忽略触觉请求。
在iPhone 6S,你的设备可以拨打UIFeedbackGenerator,但会发生什么,因为taptic硬件没有出现在手机上。
触觉反馈引擎已经在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/