秘密は、手動で動作を実装する必要があり、それは痛みです。
あなたが取るために持っているいくつかのステップがあります:
ステップ1:キーボード通知を登録
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillBeHidden:) name:UIKeyboardWillHideNotification object:nil];
}
ステップ2:キーボードは
表示されたときに、コンテンツのインセットのサイズを変更するには
- (void)keyboardWasShown:(NSNotification *)notification {
NSDictionary* info = [notification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0f, 0.0f, kbSize.height, 0.0f);
self.tableview.contentInset = contentInsets;
self.tableview.scrollIndicatorInsets = contentInsets;
[self.scrollView scrollRectToVisible:self.selectedView.frame animated:YES];
}
これは、あなたのクラスのプロパティが"selectedView"これを行う他の方法がありますが、主なものは、何らかの形でユーザーが見なければならないビューを知る必要があることです。
手順3:キーボードが消えたとき、あなたのテーブルビューをリセット
- (void)keyboardWillBeHidden:(NSNotification *)notification {
UIEdgeInsets contentInsets = UIEdgeInsetsZero;
self.tableview.contentInset = contentInsets;
self.tableview.scrollIndicatorInsets = contentInsets;
}
ステップ4:通知のために登録を解除し
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidHideNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
}
彼の質問はによって隠さテキストフィールドを持つ回避する方法でありますキーボード – kubi