我需要振动iOS设备,不支持振动的设备,会发出哔声.
为此我正在使用
Import AudioToolBox.framework #import <AudioToolBox/AudioToolBox.h> AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
它在iPhone设备上振动,但iPad和iPod上没有声音.虽然反驳说它会播放声音.我做错了什么?
http://blog.mugunthkumar.com/coding/iphone-tutorial-better-way-to-check-capabilities-of-ios-devices/
解决方法
尝试设置AudioSession:
#import <AudioToolBox/AudioToolBox.h> AVAudioSession *audioSession = [AVAudioSession sharedInstance]; NSError *err = nil; [audioSession setCategory: AVAudioSessionCategoryPlayback error:&err]; AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); //or: AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);