UISearchBar 和 resignFirstResponder
我有一个非常基本的 UITableView,带有附加的 UISearchBar,下面是 UITableView 为空时发生的流程
,用户点击 UISearchBar,然后调出键盘。 一旦用户点击“搜索”按钮,
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[searchBar resignFirstResponder]; //move the keyboard out of the way
//Code....
}
效果就很好,并将键盘移开,并填充 UITableView。 问题在于任何后续的搜索尝试。
发生与之前相同的步骤,但是键盘永远不会消失。我有一种感觉,有其他东西正在成为响应者,我只需要一点清晰度来理解实际发生的事情。
I have a very basic UITableView with an attached UISearchBar, and here's the flow of what happens
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....
}
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果没有看到你的代码,很难猜测。但是,如果您包括:
所有视图都将辞去第一响应者。
Without seeing your code it is difficult to guess. However, if you include:
all views will resign first responder.
并不完美,但确实适合我的情况。如果没有 dispatch_after 将无法工作
Not perfect but did work for my case. Will not work without dispatch_after