Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect keyboard type changes with the size, type, suggestion bar height of new keyboard type?

Is there any way to detect keyboard types changes with the size, type and suggestion bar height, change like from English keyboard to Hindi which contains some kind of suggestion bar (see screenshot).

Normal English Keyboard

enter image description here enter image description here

First Problem

After changing to Hindi LIPI - When just I changed, everthing is fine because size of english and hindi keyboard is same, but after start typing Hindi Lipi suggestion cover the TextField

enter image description here enter image description here

Second Problem

After changing to Emoji - Emoji keyboard hight little bit more as compare to english, So again keyboard cover the TextField.

enter image description here

like image 942
Vineet Choudhary Avatar asked Dec 19 '22 19:12

Vineet Choudhary


2 Answers

Add an observer for a notification named "UIKeyboardWillChangeFrameNotification".

The "userInfo" dictionary for the notification has multiple frames of the keyboard on the screen.

adding an observer

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(logNotification:) name:UIKeyboardWillChangeFrameNotification object:nil];

selector with the logger

- (void)logNotification:(NSNotification *)notification {

    NSLog(@"%@", notification);
}

userInfo dictionary content

userInfo = {
    UIKeyboardAnimationCurveUserInfoKey = 7;
    UIKeyboardAnimationDurationUserInfoKey = 0;
    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 216}}";
    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 441.5}";
    UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 460}";
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 315}, {320, 253}}";
    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 352}, {320, 216}}";
    UIKeyboardIsLocalUserInfoKey = 1;
}}
like image 56
Blazej SLEBODA Avatar answered Feb 09 '23 13:02

Blazej SLEBODA


Same problem i too faced. And I resolved by using below code

CGSize keyboardSize = [aNotification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue].size;

Use UIKeyboardFrameEndUserInfoKey instead of using UIKeyboardFrameBeginUserInfoKey.

like image 32
QuocTV Avatar answered Feb 09 '23 13:02

QuocTV