iOS Code Snippet Keyboard will hide notification

The KeyboardStatePage event is raised before the keyboard becomes visible and after the keyboard is hidden.
There are cases where you want to do something right before the keyboard is closed. For example, to start moving a view.

1. Add to Main module at the bottom:
#if OBJC
@interface B4IViewController (KeyboardWillHide)
@implementation B4IViewController (KeyboardWillHide)
- (void) addWillHide {
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardWillHideNotification object:nil];
#end if

2. In B4XPage_Created:
#if B4i
Dim no As NativeObject = B4XPages.GetNativeParent(Me) 'or Page1 in non-B4XPages project.
no.RunMethod("addWillHide", Null)
#End If

The B4XPage_KeyboardStateChanged will be raised twice with height = 0.
Last edited: