Insert content to move table view when keyboard appears
im stuck with simple problem of moving my desk when the keyboard shows. I don't want to move the frame with animation, instead I want to use content insertion to move the table view.
my notice is called bt, it doesn't move the table view.
- (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");
}
+3
source to share
1 answer
What I think you are trying to do here is to reduce the scrollable area of the table so that the keyboard does not overlap the table. In this case, perhaps you should put
UIEdgeInsets e = UIEdgeInsetsMake(0, 0, keyboardBounds.size.height, 0);
instead of keyboardBounds.size.width
. If you want to "move" a table, you can only do so by changing it frame.origin
or her center
.
+2
source to share