Programmatically make the iPhone vibrate [duplicat

2019-03-08 12:12发布

Possible Duplicate:
Making the iPhone vibrate

How can you programmatically make the iPhone vibrate?

Any ideas, or tutorial links appreciated.

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-03-08 12:30

You can use

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); 

Note that you need to add the AudioToolbox framework and import the following header file:

#import <AudioToolbox/AudioServices.h>
查看更多
男人必须洒脱
3楼-- · 2019-03-08 12:35

To clarify the add(ing) the AudioToolbox framework portion of this answer:

  1. click the project from Project Navigator
  2. click the target from the left-hand navigator
  3. click Build Phases section at the top
  4. expand the Link Binary With Libraries section
  5. click little + (plus) sign
  6. type AudioToolbox.framework
  7. click Add
查看更多
登录 后发表回答