- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField 
{ 
    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(done:)]; 
    tapGestureRecognizer.numberOfTapsRequired = 1; 
    [self.view addGestureRecognizer: tapGestureRecognizer];   //只需要点击非文字输入区域就会响应hideKeyBoard 
    [tapGestureRecognizer release]; 
    return YES; 
} 
 
-(void)done:(id)sender 
{ 
    for (UIView *view in self.view.subviews) { 
        if ([view isKindOfClass:[UITextField class]]) { 
            [view resignFirstResponder]; 
        } 
    } 
}

发布评论

分享到:

IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

iOS通过访问系统通讯录,获取选择用户的全名和电话详解
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。