我有一个聊天屏幕,它使用视图控制器的inputAccessoryView
来显示工具栏(用于文本输入,发送按钮+其他自定义类型),并在导航栏和底部之间有一个表格视图边距。
override var inputAccessoryView: UIView {
return inputToolbar
}
除了一个案例外,一切都很好;视图控制器的初始推送。当它被推开时,表格视图的内容从后面动画输入附件视图。
我希望内容已经修复输入附件视图 - 任何建议的实现方式?
答案 0 :(得分:0)
获取Indexpath并根据UIKeyboard Height更改UITableview内容Offset
func keyboardWillShow(notification: NSNotification) {
if ((notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue()) != nil {
//self.view.frame.origin.y -= keyboardSize.height
var userInfo = notification.userInfo!
var keyboardFrame:CGRect = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).CGRectValue()
keyboardFrame = self.view.convertRect(keyboardFrame, fromView: nil)
var contentInset:UIEdgeInsets = self.tbl.contentInset
contentInset.bottom = keyboardFrame.size.height
self.tbl.contentInset = contentInset
//get indexpath
let indexpath = NSIndexPath(forRow: 1, inSection: 0)
self.tbl.scrollToRowAtIndexPath(indexpath, atScrollPosition: UITableViewScrollPosition.Top, animated: true)
}
}
func keyboardWillHide(notification: NSNotification) {
if ((notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue()) != nil {
let contentInset:UIEdgeInsets = UIEdgeInsetsZero
self.tbl.contentInset = contentInset
}
}