IPhone SDK: how to determine keyboard type in UIKeyboardDidShowNotification?

I need to know the current type of keyboard. I set the instance variable to

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField 

However, testing showed that this is not always reliable due to the asynchronous nature of notifications.

I am wondering if someone can tell me how to determine the current type of keyboard inside the notification?

 - (void)keyboardDidShow:(NSNotification *) { // Need way to determine keyboard type here } 

Thanks.

+4
source share
1 answer

If you are asking for a keyboard language that can only be made in iOS4.2 and later using the UITextInputMode method : +[UITextInputMode currentInputMode];

If you need a size (because depending on the language whose size can change), it's easy to get the size from the object for the key UIKeyboardBoundsUserInfoKey

 - (void)keyboardWasShown:(NSNotification*)aNotification{ NSDictionary* info = [aNotification userInfo]; NSValue* aValue = [info UIKeyboardFrameEndUserInfoKey]; CGSize keyboardSize = [aValue CGRectValue].size; //I just got the size! ... do something with it } 
+4
source

Source: https://habr.com/ru/post/1334763/


All Articles