在iOS 6中,我使用了这一行:
NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:@"Tock" ofType:@"aiff"];
获取系统tock声音的路径。一切都很好。现在,自iOS 7以来,(null)将作为路径返回。
谁能告诉我tock声音发生了什么?
我已经尝试重新链接UIKit.framework库并得到了相同的结果。我几乎找不到这条线改变结果的原因。
感谢您的帮助!
答案 0 :(得分:8)
快速研究SDK的资源,它不再存在了。
[dbarden@Daniels-MacBook-Pro-3/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs]
[16:24:03]% find . -name Tock.aiff
./iPhoneSimulator5.1.sdk/System/Library/Frameworks/UIKit.framework/Tock.aiff
./iPhoneSimulator6.0.sdk/System/Library/Frameworks/UIKit.framework/Tock.aiff
./iPhoneSimulator6.1.sdk/System/Library/Frameworks/UIKit.framework/Tock.aiff
答案 1 :(得分:8)
iOS中所有可用系统声音的列表:iOSSystemSoundsLibrary。
您可以使用这个小型演示应用程序测试所有声音
答案 2 :(得分:3)
这篇帖子在谷歌上是关于这个话题的首选,所以我会添加一个替代答案,花了我太多时间来找到。
该文件不再包含在com.apple.UIKit包中,因为它不再用于直接使用。从iOS 4.2开始,播放此声音的方法是
[[UIDevice currentDevice] playInputClick];
希望这可以防止其他人浪费时间尝试寻找替代解决方案。
答案 3 :(得分:2)
我在7.0 base sdk上的iPhone模拟器上尝试过类似的搜索:
find . -name *.aiff
./System/Library/CoreServices/SpringBoard.app/lock.aiff
./System/Library/CoreServices/SpringBoard.app/SIMToolkitCallDropped.aiff
./System/Library/CoreServices/SpringBoard.app/SIMToolkitGeneralBeep.aiff
./System/Library/CoreServices/SpringBoard.app/SIMToolkitNegativeACK.aiff
./System/Library/CoreServices/SpringBoard.app/SIMToolkitPositiveACK.aiff
./System/Library/CoreServices/SpringBoard.app/SIMToolkitSMS.aiff
./System/Library/CoreServices/SpringBoard.app/ussd.aiff
./System/Library/PrivateFrameworks/AOSNotification.framework/findme_alarm_2.aiff
./System/Library/PrivateFrameworks/AOSNotification.framework/findme_alarm_3.aiff
./System/Library/PrivateFrameworks/AOSNotification.framework/findme_alarm_4.aiff
答案 4 :(得分:1)
声音不再包括在内,我没有看到任何其他解释
答案 5 :(得分:0)
以下是tock.aiff文件的副本。
答案 6 :(得分:-1)
试试这个......
NSString *path = [NSString stringWithFormat:
@"/System/Library/Audio/UISounds/%@.%@", @"Tock", @"caf"];
它在ios7