diff --git a/README.md b/README.md index 460b344..e2225dd 100644 --- a/README.md +++ b/README.md @@ -94,11 +94,28 @@ This event fires when the keyboard will be shown or when the keyboard frame resi alert('Keyboard height is: ' + e.keyboardHeight); } + Properties ----------- keyboardHeight: the height of the keyboard in pixels +native.keyboardchange (iOS ONLY) +================= + +This event fires when the keyboard will be shown when the keyboard frame resizes (when switching between keyboards for example) + + window.addEventListener('native.keyboardchange', keyboardChangeHandler); + + function keyboardChangeHandler(e){ + alert('Keyboard height is: ' + e.keyboardHeight); + } + + +Properties +----------- + +keyboardHeight: the height of the keyboard in pixels Supported Platforms ------------------- diff --git a/src/ios/IonicKeyboard.h b/src/ios/IonicKeyboard.h index 63935dc..d620a3f 100644 --- a/src/ios/IonicKeyboard.h +++ b/src/ios/IonicKeyboard.h @@ -3,7 +3,7 @@ @interface IonicKeyboard : CDVPlugin { @protected - id _keyboardShowObserver, _keyboardHideObserver; + id _keyboardShowObserver, _keyboardHideObserver, _keyboardChangeObserver; IMP wkOriginalImp, uiOriginalImp, nilImp; Method wkMethod, uiMethod; } diff --git a/src/ios/IonicKeyboard.m b/src/ios/IonicKeyboard.m index d072ca7..56e6423 100644 --- a/src/ios/IonicKeyboard.m +++ b/src/ios/IonicKeyboard.m @@ -50,8 +50,18 @@ - (void)pluginInitialize { //deprecated [weakSelf.commandDelegate evalJs:@"cordova.fireWindowEvent('native.hidekeyboard'); "]; }]; + + _keyboardChangeObserver = [nc addObserverForName:UIKeyboardDidChangeFrameNotification + object:nil + queue:[NSOperationQueue mainQueue] + usingBlock:^(NSNotification* notification){ + CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; + [weakSelf.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireWindowEvent('native.keyboardchange', {'keyboardHeight': %@});", [@(keyboardSize.height) stringValue]]]; + }]; + } + - (BOOL)disableScroll { return _disableScroll; }