I tried this code : in viewWillAppear :
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillDisappear), name: Notification.Name.UIKeyboardWillHide, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillAppear), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
and :
@objc func keyboardWillAppear(notification:NSNotification) {
print("keyboard appear")
var info = notification.userInfo
let keyBoardSize = info![UIKeyboardFrameEndUserInfoKey] as! CGRect
scrollCreateEditContact.contentInset = UIEdgeInsetsMake(0.0, 0.0, keyBoardSize.height, 0.0)
scrollCreateEditContact.scrollIndicatorInsets = UIEdgeInsetsMake(0.0, 0.0, keyBoardSize.height, 0.0)
}
@objc func keyboardWillDisappear(notification:NSNotification) {
print("keyboard disappear")
scrollCreateEditContact.contentInset = UIEdgeInsets.zero
scrollCreateEditContact.scrollIndicatorInsets = UIEdgeInsets.zero
}
and result is :
what I want is that textfield did not covered by keyboard when keyboard appear like this :
That code only work on textfield that is not inside tableView. But when I click textfield inside tableView and log it "keyboard appear" always detected.
What is the correct code for textfield inside tableView not covered by keyboard when keyboard appear?