Are there any other iOS system sounds available other than 'tock'?

后端 未结 2 1418
半阙折子戏
半阙折子戏 2020-12-14 19:29

I have implemented an alternative keyboard on my first iPhone app. I would like to play a sound when a button is pressed. The default click sound when the standard keyboard

2条回答
  •  北海茫月
    2020-12-14 20:03

    Try UIDevice's playInputClick:

    [[UIDevice currentDevice] playInputClick];
    

    From the documentation:

    Use this method to play the standard system keyboard click in response to a user tapping in a custom input or keyboard accessory view. A click plays only if the user has enabled keyboard clicks in Settings > Sounds, and only if the input view is itself enabled and visible.

    Make sure you adopt the UIInputViewAudioFeedback protocol in your input view class, and implement the enableInputClicksWhenVisible delegate method to return YES, as per the documentation.

    EDIT - For implementation of delegate methods, check out Apple's documentation on custom input views.

提交回复
热议问题