陈斌彬的技术博客

Stay foolish,stay hungry

UITextField 如何实现点击空白处收起键盘

self.userInteractionEnabled = YES;

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fingerTapped:)];

[self.view addGestureRecognizer:singleTap];


-(void)fingerTapped:(UITapGestureRecognizer *)gestureRecognizer

{

    [self.view endEditing:YES];

}