I have a custom keyboard extension. And I need to know when my keyboard is shown/hidden. I read this article, this block:
- (void)registerForKeyboardNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
}
// Called when the UIKeyboardDidShowNotification is sent.
- (void)keyboardWasShown:(NSNotification*)aNotification
{
}
// Called when the UIKeyboardWillHideNotification is sent
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{
}
But this code implements into app. The addObserver
argument self
means it. So, how can I get an object from my host app (it could be any app with text field) to pass for register notifications?
Or is three other options to register if keyboard is shown/hidden?
isfirstResponder also from extension - not an option, i suppose.