隐藏键盘的基本操作

全局隐藏键盘

[[[UIApplication sharedApplication] keyWindow] endEditing:YES];

滚动ScrollView隐藏键盘

scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;

点击ScrollView隐藏键盘

//加一个tap手势
tap.cancelsTouchesInView = YES
//然后在响应方法中写上
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];

你可能感兴趣的:(隐藏键盘的基本操作)