Vibrate for a long time?

流过昼夜 提交于 2019-12-10 19:34:45

问题


I want to make an app where while the user is pushing down a button the phone vibrates until the user releases the button.

Ive searched around and I haven't found a way to make it a long vibrate, except for a very old tutorial from 2009 which seems to be outdated.


回答1:


It's not allowed by Apple to use the vibration as you want to:

Vibration. It is not permitted to use continuous vibration in your apps – short bursts as warnings is all that is allowed. Don’t bother trying to set up a timer to keep the vibration going, it will cause your app to be rejected.

It's not the method, but the result, that's not permitted.

Source: http://10base-t.com/unofficial-appstore-rejection-criteria/




回答2:


Look on these options,

1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

also
Making the iPhone vibrate

And, you need to import AudioToolBox framework,

 #import <AudioToolbox/AudioServices.h>



回答3:


AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

repeat this line in between you start-stop vibrate. don't forgot to add and import

#import <AudioToolbox/AudioToolbox.h> 

framework to your project.



来源:https://stackoverflow.com/questions/22836211/vibrate-for-a-long-time

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