网络编程

当前位置:永利402游戏网站-永利402com官方网站 > 网络编程 > 导航栏的UITextField点击下边视图隐蔽键盘

导航栏的UITextField点击下边视图隐蔽键盘

来源:http://www.xtcsyb.com 作者:永利402游戏网站-永利402com官方网站 时间:2019-09-16 12:04

自定义导航栏上边有UITextField,不过当键盘弹出时候怎么点击视图弹下去啊?非常少说,贴出如下代码本身知道:

- setUpForDismissKeyboard { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; UITapGestureRecognizer *singleTapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAnywhereToDismissKeyboard:)]; NSOperationQueue *mainQuene =[NSOperationQueue mainQueue]; [nc addObserverForName:UIKeyboardWillShowNotification object:nil queue:mainQuene usingBlock:^(NSNotification *note){ [self.view addGestureRecognizer:singleTapGR]; }]; [nc addObserverForName:UIKeyboardWillHideNotification object:nil queue:mainQuene usingBlock:^(NSNotification *note){ [self.view removeGestureRecognizer:singleTapGR]; }];}- tapAnywhereToDismissKeyboard:(UIGestureRecognizer *)gestureRecognizer { [self.search endEditing:YES];}

本文由永利402游戏网站-永利402com官方网站发布于网络编程,转载请注明出处:导航栏的UITextField点击下边视图隐蔽键盘

关键词:

上一篇:没有了

下一篇:没有了