ios - How to detect when user changes keyboards? -


Is there a way to find out that when the user changes the keyboard type, especially in this case the Emoji keyboard for?

After the text "itemprop =" text "> UITextInputMode

you can use currentInputMode

The UITextInputMode class example shows current text-input mode. You can use this object to determine the primary language currently used for text input.

You can check the Emoji keyboard:

  NSString * language = [[UITextInputMode current Inputmod] primary language]; BOOL isEmoji = [language acquisition: @ "emoji"]; If (isEmoji) {// do something}  

If you change via UITextInputCurrentInputModeDidChangeNotification can be informed about the input mode. It will post in the current input mode after the change.

This is a simple app that prints NSLog whenever any changes occur:

  - (zero) see { Viewedload]; [[NSNotificationCenter defaultCenter] addObserver: Self selector: @selector (changeInputMode) Name: UITextInputCurrentInputModeDidChangeNotification Object: Zero];}} - (zero) changeInputMode: (NSNotification *) Notification {NSString * inputMethod = [[UITextInputMode currentInputMode] primary language]; NSLog (@ "inputMethod =% @", inputMethod); }  

or would you prefer:

  import UIKit class ViewController: UIViewController {viewDidLoad () {super.viewDidLoad (function override) NSNotificationCenter.defaultCenter ( ) .addObserver (self selector: "changeInputMode:", name: UITextInputCurrentInputModeDidChangeNotification, object: nil)} function changeInputMode (notification: NSNotification) {go inputMethod = UITextInputMode.currentInputMode () primaryLanguage println ( "inputMethod: \ (inputMethod)") . }}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -