Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect word suggestion bar on top of keyboard is showed or not?

I am developing a chat app and i found a problem when keyboard appear method. I am using UIKeyboardDidShowNotification to move my chat textview and button on top of the keyboard. But my chat textview is hidden by word sugesstion tool bar when showing word suggestion or changing keyboard to other language like Japanese. Keyboard height got by UIKeyboardNotification is late. And so, how to detect that suggestion toolbar is shown or not?

- (void)keyboardWasShown:(NSNotification*)aNotification
{
    NSDictionary *userInfo = [aNotification userInfo];
    CGSize kbSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
    CGRect rectTable = rTable;
    rectTable.origin.y -= kbSize.height;
    CGRect rectToolBar = rToolbar;
    rectToolBar.origin.y -= kbSize.height;

    [UIView animateWithDuration:0.25f
                     animations:^{
                         [self.tableView setFrame:rectTable];
                         [self.toolBar setFrame:rectToolBar];
                     }
    ];
}

If changing textview location doen't work, is there another way to put textview on top of the keyboard?

like image 468
Gates Avatar asked Dec 16 '22 05:12

Gates


1 Answers

Instead of using this,

CGSize kbSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;

try this

CGSize kbSize = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
like image 59
Karthikeyan Avatar answered Feb 09 '23 00:02

Karthikeyan