问题
My app contains a custom control that copies the behaviour of the iOS standard keyboard.
I can successfully play the system keyboard click sound with this code:
UIDevice.current.playInputClick()
On iOS 9 and below there is only one click sound and this call is all I need. On iOS 10, there are different click sounds for regular keys, for the backspace key and for other special keys.
What is the official way to play these additional sounds? Do I have to use the alternative way from the linked answer? The documentation for playInputClick()
does not mention anything.
There is an answer that suggests to play the new click sounds using AudioServicesPlaySystemSound
. But another answer says that these IDs might not point to the latest system click sounds in a future version of iOS. Another problem with the workaround is that there seems to be no way to check if the user has enabled keyboard clicks in the system settings (link).
回答1:
The url below could help with finding proper sound: https://github.com/TUNER88/iOSSystemSoundsLibrary
As of October 2019, these are the sound IDs
Press Click - ID: 1104
Press Delete - ID: 1155
Press Modifier - ID: 1156
来源:https://stackoverflow.com/questions/39670466/official-way-to-use-the-new-keyboard-click-sounds-in-ios-10