Can't get playInputClick working
Asked Answered
J

1

8

I read a lot of documentations and topics about playing keyboard clicks, but I can't get it to work in my app...

I designed a custom keyboard (as a UIView subview), which adopts the UIInputViewAudioFeedback protocol, and returns YES for the enableInputClicksWhenVisible method.

But when I call [[UIDevice currentDevice] playInputClick], nothing happens (whereas I can hear the click when I use the default keyboards).

In the Apple UIKit framework reference, it's written that it should work "only if the input view is itself enabled and visible". My view is obviously visible, and even if I change the superclass from UIView to UIControl, and set self.enabled = YES, it doesn't work either...

I saw a lot of solutions like AudioServicesPlaySystemSound(1104); but I didn't even tried because I don't want to play clicks if the user disabled the keyboard clicks in settings.

Why don't the "official" solution work? It doesn't seem to be deprecated in iOS 8...

Thanks a lot

Thomas

Jenisejenkel answered 30/10, 2014 at 18:17 Comment(0)
P
0

Did you adopt the UIInputViewAudioFeedback protocol and override enableInputClicksWhenVisible?

To enable a custom input or accessory view for input clicks, perform the following two steps:

1) Adopt the UIInputViewAudioFeedback protocol in your input view class.

2) Implement the enableInputClicksWhenVisible delegate method to return true.

https://developer.apple.com/documentation/uikit/uidevice/1620050-playinputclick

Perpetuity answered 24/1, 2020 at 0:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.