标签:selector select ble rdd bsp edit tableview name content
extension UITableView {
func addNotifications() {
NotificationCenter.default.addObserver(self, selector: #selector(boardWillShow(not:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(boardDidHide(not:)), name: NSNotification.Name.UIKeyboardDidHide, object: nil)
}
func boardWillShow(not: NSNotification) {
if let userInfo = not.userInfo {
if let keyBoardRect = userInfo[UIKeyboardFrameEndUserInfoKey] as? CGRect {
UIView.animate(withDuration: 0.25) {
self.contentInset = UIEdgeInsetsMake(0, 0, keyBoardRect.size.height, 0)
}
}
}
}
func boardDidHide(not: NSNotification) {
UIView.animate(withDuration: 0.25) {
self.contentInset = .zero
}
}
func `deinit`() {
NotificationCenter.default.removeObserver(self)
}
}
在所用的类中直接使用
self.tableView.addNotifications()
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
self.view.endEditing(true)
}
UITableView 键盘覆盖UITableViewCell的输入框解决方法(swift)
标签:selector select ble rdd bsp edit tableview name content
原文地址:http://www.cnblogs.com/huangbiyong/p/6902204.html