xcode 让 iPhone 振动:AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) 未声明

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10970162/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:33:16  来源:igfitidea点击:

Make iPhone vibrate: AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) undeclared

iphonexcodeaudiovibration

提问by Ben Lu

I want to make iPhone vibrate and I found the code

我想让 iPhone 振动,我找到了代码

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

but Xcode 4.3.2 reports error: undeclared identifier kSystemSoundID_Vibrate

但是 Xcode 4.3.2 报错:undeclared identifier kSystemSoundID_Vibrate

What's the problem?

有什么问题?

回答by skram

Try:

尝试:

AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);

EDIT: Also make sure you import AudioToolbox.framework

编辑:还要确保您导入AudioToolbox.framework

  • #import <AudioToolbox/AudioToolbox.h>
  • #import <AudioToolbox/AudioToolbox.h>