I am using UIKeyboardWillShowNotification
and UIKeyboardWillHideNotification
to handle keyboard.
This is the function called when keyboard is shown :
-(void) keyboardWillShow:(NSNotification *)note
{
CGRect keyboardBounds;
//[[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue: &keyboardBounds];
NSValue* keyboardFrameBegin = [note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey];
keyboardBounds = [keyboardFrameBegin CGRectValue];
}
I get keyboardBounds = (0, 524, 320, 44) and I am using 5s. No idea why origin.y is coming 524 (should be somewhere near 300) and height as 44 !!
I have also tried the commented line. Both ways keyboard bound comes out to be 44. This issue comes only for swift keyboard.
Same as this issue
Well the issue is with swift keyboard, the method -(void) keyboardWillShow:(NSNotification *)note
is called three times, and every time it returns three different origin.y value and height first time it gives keyboardBounds = (0, 524, 320, 44), second time it it gives keyboardBounds = (0, 308, 320, 260) and finally the third time when it is called it returns keyboardBounds = (0, 271, 320, 297).
As third party keyboard sizes are not fixed.. their sizes get fixed as per how view lay it out, so as similar to autolayout case(viewDidLoad,viewWillAppear viewWillLayout,viewDidLayout and then viewDidAppear, so exact frame you get to know in viewDidAppear or viewDidLayout, where View have been laid out.), Here it gets exact frame when it's view get completely laid out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With