首先导入 #import<AudioToolbox/AudioToolbox.h>
soundID号:http://iphonedevwiki.net/index.php/AudioServices
//同时调用铃声及震动:
SystemSoundID soundID = 1007;
AudioServicesPlaySystemSound(soundID);
//仅振动:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
用户自定义音效
//音效文件路径
NSString *path = [[NSBundle mainBundle] pathForResource:@"message" ofType:@"wav"];
//组装并播放音效
SystemSoundID soundID;
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);
//声音停止
AudioServicesDisposeSystemSoundID(soundID);