拦截响应事件
extension UITableView {
open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let view = super.hitTest(point, with: event)
// give up first response
if let v = view ,(v.isKind(of: UITextField.self) || v.isKind(of: UITextView.self)){
return v
}
self.endEditing(true)
return view
}
}
(v.isKind(of: UITextField.self) || v.isKind(of: UITextView.self) 这句有待商榷
Demo
.../TodoDetailViewController.swift
网友评论