iOS Question Keyboard will show notification

Alexander Stolte

Expert
Licensed User
Longtime User
With this code we can trigger the KeyboardStateChanged event directly as soon as the keyboard close.

I need the same when the keyboard is opened, I found the following in the apple documentation:

I can't manage to extend the code to this function:
B4X:
#if OBJC
@end
@interface B4IViewController (KeyboardNotifications)
@end
@implementation B4IViewController (KeyboardNotifications)
- (void) addWillHide {
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardWillHideNotification object:nil];
}

- (void) addWillShow {
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];
}
#end if

What am I doing wrong?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The UIKeyboardWillShowNotification is the notification monitored internally.

This is the code from the framework:
B4X:
if ([B4IObjectWrapper hasMethod:self :@"_keyboardstatechanged:"]) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];
    }
 
Upvote 0
Top