当 searchdisplaycontroller 处于活动状态时帮助隐藏键盘
我在视图中添加了一个 TapgestureRecognizer,这样当用户点击搜索栏但随后决定不键入时,用户可以点击键盘后面的屏幕,键盘就会消失。这是我在 viewdidload 中的代码:
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[self.view addGestureRecognizer:tapGesture];
[tapGesture release];
然后处理点击:
- (void)handleTap:(UITapGestureRecognizer *)gesture {
if (self.searchDisplayController.active == YES) {
[self.searchDisplayController setActive:NO];
}
}
但是,现在我的其他按钮(例如选项卡栏中的项目)不可用。我还缺少其他东西吗?谢谢!
I added a tapgesturerecognizer to my view so when the user hits the search bar, but then decides to not type, the user can tap on the screen behind the keyboard, and the keyboard will disappear. this is my code in viewdidload:
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[self.view addGestureRecognizer:tapGesture];
[tapGesture release];
Then to handle the tap:
- (void)handleTap:(UITapGestureRecognizer *)gesture {
if (self.searchDisplayController.active == YES) {
[self.searchDisplayController setActive:NO];
}
}
However, now my other buttons like items in the tabbar are not available. Am I missing something else? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
此操作将隐藏键盘而不停用搜索模式。
Try
This will hide the keyboard without deactivating search mode.