IOS8 keyboard issues

I am working on an iOS 8 custom keyboard extension right now and there are some issues that I cannot figure out.

First, I think the methods UITextInputDelegate

are not working as I expected.

Does it sound right right: selectionWillChange:

and selectionDidChange:

should the methods be called when the user clicks on the input area? And the methods textWillChange:

and textDidChange:

should be called whenever the text literally changes?

Actually, I noticed that when I changed the selection in the text input area, textWillChange:

and are called textDidChange:

, and I can't figure out which other two methods are being called in what state. If anyone knows about using these delegate methods, please let me know.

Secondly, I know the method playInputClick:

can be used to virtualize keystrokes on the keyboard. Since this is normally applicable, I found it impossible to apply in an iOS 8 custom keyboard extension. My app consists of one keyboard controller and a custom view that UIView subclasses are added to this view controller. My approach is that the delegate is UIInputViewAudioFeedback

declared in this custom view, the enableInputClicksWhenVisible method returns YES

, the class method that calls [[UIDevice currentDevice] playInputClick]

, then this method is called wherever keyboard sound is required: which doesn't work for everything.

How wrong am I my approach? If anyone has succeeded in using the method playInputClick

, share your wisdom.

thank

+3


source to share


2 answers


Your best bet is to play audio in a queue rather than in a UI key handler

func playPressKeySound() {
    let PRESS_KEY_DEFAULT_SOUND_ID: SystemSoundID = 1104
    dispatch_async(dispatch_get_main_queue()) {
            AudioServicesPlaySystemSound(PRESS_KEY_DEFAULT_SOUND_ID)
        }
}

      



NOTE: this only works if full access mode is enabled on the keyboard, so it is best to check that there is full access before calling, otherwise the keyboard may suffer from long pauses.

+6


source


For your second question try AudioServicesPlaySystemSound



#define PRESS_KEY_DEFAULT_SOUND_ID 1104

- (void)playPressKeySound {
    if (self.openPressSound) {
        AudioServicesPlaySystemSound(PRESS_KEY_DEFAULT_SOUND_ID);
    }
}

      

0


source







All Articles