在自己的程序中,有的时候需要打开系统声音、震动之类的!下面这个就可能会帮助你解决相关问题:
首先在自己的工程中添加AudioToolbox.framework库,在.m文件中添加头文件:#import <AudioToolbox/AudioToolbox.h>
然后在需要打开声音的地方添加代码:AudioServicesPlaySystemSound(audioID);
其中audioID就是你需要打开系统声音的id号:附上系统对应提示音对照表:
There are some predefined system sounds, for the system sound ID in the range 1000 to 2000 (decimal), as shown below (from 2.0 to 5.0 beta). The system sounds are all stored in/System/Library/Audio/UISounds/.
Sound ID | File name (iPhone) | File name (iPod Touch) | Category | Note |
---|---|---|---|---|
1000 | new-mail.caf | new-mail.caf | MailReceived | |
1001 | mail-sent.caf | mail-sent.caf | MailSent | |
1002 | Voicemail.caf | Voicemail.caf | VoicemailReceived | |
1003 | ReceivedMessage.caf | ReceivedMessage.caf | SMSReceived | |
1004 | SentMessage.caf | SentMessage.caf | SMSSent | |
1005 | alarm.caf | sq_alarm.caf | CalendarAlert | |
1006 | low_power.caf | low_power.caf | LowPower | |
1007 | sms-received1.caf | sms-received1.caf | SMSReceived_Alert | |
1008 | sms-received2.caf | sms-received2.caf | SMSReceived_Alert | |
1009 | sms-received3.caf | sms-received3.caf | SMSReceived_Alert | |
1010 | sms-received4.caf | sms-received4.caf | SMSReceived_Alert | |
1011 | - | - | SMSReceived_Vibrate | |
1012 | sms-received1.caf | sms-received1.caf | SMSReceived_Alert | |
1013 | sms-received5.caf | sms-received5.caf | SMSReceived_Alert | |
1014 | sms-received6.caf | sms-received6.caf | SMSReceived_Alert | |
1015 | Voicemail.caf | Voicemail.caf | - | Available since 2.1 |
1016 | tweet_sent.caf | tweet_sent.caf | SMSSent | Available since 5.0 |
1020 | Anticipate.caf | Anticipate.caf | SMSReceived_Alert | Available since 4.2 |
1021 | Bloom.caf | Bloom.caf | SMSReceived_Alert | Available since 4.2 |
1022 | Calypso.caf | Calypso.caf | SMSReceived_Alert | Available since 4.2 |
1023 | Choo_Choo.caf | Choo_Choo.caf | SMSReceived_Alert | Available since 4.2 |
1024 | Descent.caf | Descent.caf | SMSReceived_Alert | Available since 4.2 |
1025 | Fanfare.caf | Fanfare.caf | SMSReceived_Alert | Available since 4.2 |
1026 | Ladder.caf |