I've registered for keyboard notifications using this code:
_keyboardShowObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, OnKeyboardNotification);
OnKeyboardNotification never fires.
So I changed it so that I am now able to see all the notifications using this code:
_keyboardShowObserver = NSNotificationCenter.DefaultCenter.AddObserver(null, OnKeyboardNotification);
I printed out to the output window the name of each of the notifications received. The only keyboard related notifications I see when bringing up the keyboard are:
UIKeyboardCandidateCorrectionDidChangeNotification
UIKeyboardLayoutDidChangedNotification
UIKeyboardWillChangeFrameNotification
UIKeyboardPrivateWillChangeFrameNotification
UIKeyboardDidChangeFrameNotification
UIKeyboardPrivateDidChangeFrameNotification
What am I doing wrong? Here is a complete code snippet:
RegisterForKeyboardNotifications()
{
_keyboardShowObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, OnKeyboardNotification)
_keyboardHideObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, OnKeyboardNotification)
}
private void OnKeyboardNotification(NSNotification notification)
{
Debug.WriteLine(notification.name);
}