当我尝试添加评论时,视图不会向上移动。
该文本字段仅显示在单元格中。
我在发送评论时需要弄清楚如何移动单元格。
https://i.ibb.co/nCFQBwr/Screen-Shot-2019-04-30-at-2-00-37-AM.png
@IBOutlet weak var stack: UIStackView!
let postID = "LdZwtugqxb8-Z6SfduF"
@IBOutlet weak var buttomCnstraint: NSLayoutConstraint!
var userContentArray = [UserModel]()
var commentContinerArray = [CommentModel]()
@IBOutlet weak var commentTextFieldOutLet: UITextField!
@IBOutlet weak var tableViewOutLet: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableViewOutLet.dataSource = self
tableViewOutLet.rowHeight = 171.5
tableViewOutLet.estimatedRowHeight = UITableView.automaticDimension
ObserveCommentFromPostID()
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillshow), name:UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillHide), name:UIResponder.keyboardWillHideNotification, object: nil)
}
@objc func keyboardWillshow (notification : NSNotification ) {
let kayBoard = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as AnyObject).cgRectValue
UIView.animate(withDuration: 0.3) {
self.buttomCnstraint.constant = kayBoard!.height
self.view.layoutIfNeeded()
}
}
@objc func keyboardWillHide (notification : NSNotification) {
UIView.animate(withDuration: 0.3) {
self.buttomCnstraint.constant = 0
self.view.layoutIfNeeded()
}
}