3
キーボードが表示されたときにテーブルビューを移動するという簡単な問題があります。 アニメーションを使用してフレームを移動するのではなく、コンテンツインセットを使用してテーブルビューを移動したいと考えています。キーボードが表示されたときにテーブルビューを移動するためにコンテンツが挿入される
私の通知はbtと呼ばれていますが、テーブルビューを移動しません。
- (void)keyboardWillShow:(NSNotification *)notification {
NSLog(@"%@",self.tableView1);
NSValue *keyboardBoundsValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardBounds;
[keyboardBoundsValue getValue:&keyboardBounds];
UIEdgeInsets e = UIEdgeInsetsMake(0, 0, keyboardBounds.size.height, 0);
NSLog(@"%d %d %d %d",self.tableView1.contentInset.bottom,self.tableView1.contentInset.top,self.tableView1.contentInset.left,self.tableView1.contentInset.right);
[self.tableView1 setContentInset:e];
[self.tableView1 setScrollIndicatorInsets:e];
NSLog(@"%d %d %d %d",self.tableView1.contentInset.bottom,self.tableView1.contentInset.top,self.tableView1.contentInset.left,self.tableView1.contentInset.right);
NSLog(@"%@",self.tableView1);
NSLog(@"keyboard notification");
}
私は高さを持っていました。何かをテストするために幅を書きましたが、間違ってここにコピーされました。 –
私は確信していません、nsvalueはあなたに正しいキーボードの高さを与えますか(それは216でなければなりません)。そうでない場合は、このように試してみることができますNSNumber * keyboardHeight = [NSNumber numberWithFloat:[[[通知userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue] .size.height]; – Demz