【问题标题】:Playing system click sound in iOS keyboard extension在 iOS 键盘扩展中播放系统点击声音
【发布时间】:2014-09-27 13:56:14
【问题描述】:
【问题讨论】:
标签:
ios
audio
ios-keyboard-extension
【解决方案1】:
当您想在键盘扩展中播放系统点击声音时,请尝试此代码:
+ (void)keyboardClickSound {
// Check system preference for current setting of Keyboard Click Sound.
CFStringRef applicationID = CFSTR("/var/mobile/Library/Preferences/com.apple.preferences.sounds");
Boolean keyExistsAndHasValidFormat;
BOOL enableInputClicks
= CFPreferencesGetAppBooleanValue(CFSTR("keyboard"), applicationID, &keyExistsAndHasValidFormat);
// Note: If the key does not exist because it has never been changed by a user,
// set it to the default, YES.
if (!keyExistsAndHasValidFormat)
enableInputClicks = YES;
// Play Keyboard Click Sound, if enabled.
// Note: If Open Access=Off, no click sound.
if (enableInputClicks)
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{ AudioServicesPlaySystemSound(1104); });
}
【解决方案2】:
如果您的键盘扩展应用包含“RequestsOpenAccess”字段为 YES,
然后键盘点击声音必须需要“允许完全访问”从
切换到开启
常规 > 键盘 > 键盘 > Your_keyboard 设置。
如果它是关闭的,那么你就不能播放键盘按键声音。