カスタムキーボード(iPhone)UIKeyboardDidShowNotificationとUITableViewController
-
19-09-2019 - |
質問
IPhoneアプリでは、私のキーボードカスタムするようにな標準キーボードまれた場合に表示され、カスタムテキストフィールドが最初の対応者と非場合の方が投了の意思表示をした時点初の対応者であまた、投稿のリ UIKeyboardWillShowNotification
, UIKeyboardDidShowNotification
その隠れた側は、以下の
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithCapacity:5];
[userInfo setObject:[NSValue valueWithCGPoint:self.center]
forKey:UIKeyboardCenterBeginUserInfoKey];
[userInfo setObject:[NSValue valueWithCGPoint:shownCenter]
forKey:UIKeyboardCenterEndUserInfoKey];
[userInfo setObject:[NSValue valueWithCGRect:self.bounds]
forKey:UIKeyboardBoundsUserInfoKey];
[userInfo setObject:[NSNumber numberWithInt:UIViewAnimationCurveEaseOut]
forKey:UIKeyboardAnimationCurveUserInfoKey];
[userInfo setObject:[NSNumber numberWithDouble:thisAnimDuration]
forKey:UIKeyboardAnimationDurationUserInfoKey];
[[NSNotificationCenter defaultCenter] postNotificationName:UIKeyboardWillShowNotification
object:nil
userInfo:userInfo];
このコードは、使用で UIViewController
サブクラス.
今年iPhone OS 3.0, UITableViewController
自動的にサイズをそのtableViewのシステムのキーボードの表示と非表示を切り替え.私は今だけの作成の対3.0およびそのコントローラーもサイズ変更の場合、テーブルマカスタムキーボードが表示されたら、私に掲載同様に通知するしかしださい。の表示コントローラが設定されているdelegateを入力します。
小さなアイデアをお持ちはなぜこれかるでしょうか?で行う順調に進んでいるのでしょうか?
私は標準入力分野に沿ったカスタムなものなので、専用アプリをインストールの分野の標準キーボードを隠したとの一つです。この有益な場合のtableViewなサイズの変更めの全高となかなかリサイズし、カスタム。
解決
よくある可能性でポンとしました。からご説明いUITableViewは使用しないのUIKeyboard通知を選択するフィルタ。
でも、そのUINavigationControllerでこれを通知またはUITabBarController).
きのオーバーライド方式setFrame:drawRect:とsetNeedsDisplayのtableviewか、コールスタックです。ることができる図であるか実際のtableviewを再描画に正しいサイズです。
ものすべての可能性を、変更のサイズのtableViewを自分でです。の意見を述べ、それだけで楽しい!
他のヒント
私は似たようなを行っています。私がリコールした場合、私はちょうどあなたが送信またはシステムが送信し、その後、テーブルビューのフレームへの変更をアニメーション化のいずれかの通知にTableViewControllerのsubecibeを持つことになりました。おそらくそこに内部的に類似した何かをやっているが、私は最終的な結果は、単にシステムが通知を掲示され、両方の実行が、最終結果は同じであるべきであることをお互いに巻き付け2つのアニメーションのブロックとなりだと思います。
あなたのviewDidLoadでます:
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(keyboardWillShow:)
name: UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(keyboardDidShowOrHide:)
name: UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(keyboardWillHide:)
name: UIKeyboardWillHidewNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(keyboardDidShowOrHide:)
name: UIKeyboardDidHideNotification object:nil];
とビューコントローラで
-(void) keyboardWillShow:(id)sender {
[UIView beginAnimations];
[UIView setAnimationDuration:0.3];
self.view.frame = //Your new size
}
-(void) keyboardDidShowOrHide:(id)sender {
[UIView commitAnimations];
}
-(void) keyboardWillHide:(id)sender {
[UIView beginAnimations];
[UIView setAnimationDuration:0.3];
self.view.frame = //Your old size
}