【发布时间】:2010-10-12 16:48:47
【问题描述】:
通常我们使用 resignFirstResponder 来隐藏 iphone 应用程序中的键盘。 例如,当我们使用 UISearchBar 时,用户点击搜索按钮后,我们通过实现 searchBarSearchButtonClicked 函数来隐藏键盘,如下所示:
-(void)searchBarSearchButtonClicked:(UISearchBar*)searchBar{
NSLog(@"Search Button Click, result should be show here");
[searchBar setShowsCancelButton:NO animated:YES];
[searchBar resignFirstResponder];
self.dictTableView.allowsSelection = YES;
self.dictTableView.scrollEnabled = YES;
}
我们将 searchBar 设置为第一响应者,然后用户点击搜索按钮后键盘将隐藏。
为什么会这样?我们没有调用任何隐藏键盘的函数,只是将searchBar设置为第一响应者,为什么系统只是自动隐藏键盘?
谁能解释一下这个过程的机制?
非常感谢!
【问题讨论】:
标签: iphone cocoa-touch first-responder