我有这个UISearchDisplayController,到目前为止,它只能searchresulttableview在有人单击UISearchBar. 有没有办法让按钮完成这项任务?我会很感激我收到的任何答复。
3 回答
3
你试过[searchDisplayController.searchbar becomeFirstResponder]在你的按钮选择器里面吗?
于 2013-11-04T23:42:43.243 回答
2
查看UISearchDisplayController. 有一个active属性和一个setActive:animated:方法。
让你的按钮动作调用这个:
[theSearchController setActive:YES animated:YES];
于 2013-11-04T23:52:28.953 回答
1
由于UISearchBar扩展UIResponder就像 a 一样UITextField,您可以简单地调用becomeFirstResponder搜索栏以使其获得焦点。
[button addTarget:self action:@selector(clickedSearchBar) forControlEvents:UIControlEventTouchUpInside];
- (void)clickedSearchBar {
[searchDisplayController.searchbar becomeFirstResponder];
}
于 2013-11-04T23:44:23.927 回答