我将 TableView 与 UISearchDisplayController
结合使用 UISearchBar
。搜索栏在不合适的时候自动隐藏取消按钮,但我在模态状态下使用 View Controller - 所以我想始终显示取消按钮并在搜索取消时使用它弹出模态视图 Controller 。
有没有办法在不创建自定义搜索栏的情况下强制取消按钮保持可见?
最佳答案
你应该使用显示委托(delegate)
- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller
{
controller.searchBar.showsCancelButton = YES;
}
关于ios - 始终在 UISearchBar 中显示取消按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7191431/