カスタムキーボード拡張機能があります。また、キーボードがいつ表示/非表示になるかを知る必要があります。私はこの記事、このブロックを読みました:
- (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
{
}
しかし、このコードはアプリに実装されています。addObserver
引数はそれself
を意味します。では、ホスト アプリ (テキスト フィールドを持つ任意のアプリ) からオブジェクトを取得して、登録通知に渡すにはどうすればよいでしょうか?
または、キーボードが表示/非表示の場合に登録する他の3つのオプションはありますか?
isfirstResponder も拡張から - オプションではないと思います。