UISearchBar和resignFirstResponder [英] UISearchBar and resignFirstResponder

查看:79
本文介绍了UISearchBar和resignFirstResponder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常基本的UITableView,带有一个附加的UISearchBar,这是发生的事情的流程

I have a very basic UITableView with an attached UISearchBar, and here's the flow of what happens

UITableView为空,用户点击UISearchBar,然后弹出键盘. 一旦用户点击搜索"按钮

UITableView is empty, user taps UISearchBar, and brings up keyboard. Once the user taps the Search button

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { 
    [searchBar resignFirstResponder]; //move the keyboard out of the way
    //Code....  
}

工作正常,将键盘移开,并填充UITableView. 问题是随后进行的任何搜索尝试.

Works just fine, and moves the keyboard out of the way, and populates the UITableView. The problem is any subsequent search attempts.

发生与之前相同的步骤,但是永远不会关闭键盘.我觉得有其他事情正在成为响应者,我只需要稍微了解一下实际发生的事情即可.

The same steps as before occur, however the keyboard is never dismissed. I have a feeling something else is becoming the responder, I just need a little clarity to understand what is actually occurring.

推荐答案

如果看不到您的代码,就很难猜测.但是,如果您包括:

Without seeing your code it is difficult to guess. However, if you include:

[self.view endEditing:YES];

所有视图都会辞职第一响应者.

all views will resign first responder.

这篇关于UISearchBar和resignFirstResponder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆