What are the system sound ids for the new keyboard clicks in iOS 10?

笑着哭i 提交于 2019-12-03 17:41:24

问题


General
I'm developing a third party keyboard and am currently trying to mimic the new keyboard clicks that Apple introduced in iOS 10b4.

Current Situation
The regular click sound can be played using AudioServicesPlaySystemSound(1104) but I can't seem to find the System Sound IDs for the two new other sounds. I've found the location of their .caf equivalents but those are way too loud to use, even after adjusting their volume using AVAudioPlayer.

Question
Is it possible to obtain the system sound ids of the new click sounds?

Extra
If anyone wants the .caf file paths for personal use, here they are:

/System/Library/Audio/UISounds/key_press_click.caf
/System/Library/Audio/UISounds/key_press_delete.caf
/System/Library/Audio/UISounds/key_press_modifier.caf

回答1:


iOS 10.0 - iOS 11.0 b5

Press Click - ID: 1123

Press Delete - ID: 1155

Press Modifier - ID: 1156

Comment (1): Same IDs work for iOS 11 beta 5




回答2:


Implemented in swift using an enum (extend with your own other system sound id's):

import AudioToolbox

enum SystemSound: UInt32 {

    case pressClick    = 1123
    case pressDelete   = 1155
    case pressModifier = 1156

    func play() {
        AudioServicesPlaySystemSound(self.rawValue)
    }

}

and use like this:

@IBAction func pressedDigit(sender : UIButton) {
    SystemSound.pressClick.play()
}


来源:https://stackoverflow.com/questions/39055154/what-are-the-system-sound-ids-for-the-new-keyboard-clicks-in-ios-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!