Vibrate iPhone 6S manually like peek and pop?

 ̄綄美尐妖づ 提交于 2019-12-12 07:37:57

问题


How can I manually trigger a single click-like vibration like the ones that happen when using peek&pop, or application shortcuts?


回答1:


It seems that these guys have found a way to do it for iOS 9 for phones with Taptic Engine (including the iPhone 6S). http://unifiedsense.com/development/using-taptic-engine-on-ios.html I'm not sure if it applies to iOS 8 or any other phones. They've essentially retrieved the Taptic Engine interface from UIDevice and called actuateFeedback with an integer corresponding to Peek or Pop.

Unfortunately these apps would likely be rejected by the App Store, if that's your intention.




回答2:


This method is easy to implement and it works really well (I tried it myself)

import AudioToolbox

AudioServicesPlaySystemSound(1519) // Peek feedback
AudioServicesPlaySystemSound(1520) // Pop feedback
AudioServicesPlaySystemSound(1521) // Three pulses feedback

I hope this helps! :)



来源:https://stackoverflow.com/questions/33425586/vibrate-iphone-6s-manually-like-peek-and-pop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!