第一种:
创建一个不可见的button,将其放在其他所有元素后面,然后在该button的触发事件中写
resignFirstResponder.
第二种(更高效的一种方法):
实现
touchesBegan方法来隐藏键盘:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
[textField resignFirstResponder];
//do some other things.
}