簡體   English   中英

內容插入以在鍵盤出現時移動表格視圖

[英]content inset to move the table view when keyboard appears

我堅持一個簡單的問題,當鍵盤顯示時移動我的tableview。 我不想使用動畫移動框架,而是我想使用內容插入來移動表格視圖。

我的通知被稱為bt它沒有移動tableview。

- (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");
}

我相信你在這里嘗試做的是使表的滾動區域更小,以便不使鍵盤與表重疊。 在那種情況下,也許你應該放

UIEdgeInsets e = UIEdgeInsetsMake(0, 0, keyboardBounds.size.height, 0);

而不是keyboardBounds.size.width 如果你想“移動”表格,那么你只能通過修改它的frame.origin或它的center來做到這一點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM