3
當鍵盤顯示時,我遇到一個移動桌面視圖的簡單問題。 我不想移動框架使用動畫,而是我想使用內容插入移動表視圖。當鍵盤出現時移動桌面視圖的內容插入
我的通知被稱爲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");
}
我有身高..我寫了寬度來測試別的東西,錯誤的是在這裏複製..即時通訊只使用高度,仍然沒有工作。 – 2012-03-16 15:14:28
我不確定,nsvalue是否給你正確的鍵盤高度(應該是216);如果沒有,你可以嘗試像這樣NSNumber * keyboardHeight = [NSNumber numberWithFloat:[[[通知userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue] .size.height]; – Demz 2012-03-16 15:32:15