簡單實現點擊 textField 外面隱藏鍵盤:
1、把 textField 的父 View 設置爲繼承 UIControl 。如圖1、圖2。
2、在當前 ViewControl 中添加方法
- (IBAction)backgroundTap:(id)sender {
[self.numberstextField resignFirstResponder];
}
3、把 textField 的父 View 的 Touch Down 事件綁定到 backgroundTap 方法。
圖1
圖2