如何在 iOS9 中的 tableViewController 中以最简单的方式停止从 UISearchBar 出现的取消按钮?
那里有很多替代答案,但在 iOS9 中没有简单的目标 C 答案。
为了迅速,根据Ben的回答,
func didPresentSearchController(_ searchController: UISearchController) {
searchController.searchBar.showsCancelButton = false
}
并且不要忘记为您的搜索控制器设置委托。
searchController.delegate = self
希望这可以帮助。谢谢。
-(void) didPresentSearchController:(UISearchController *) searchController {
self.searchController.searchBar.showsCancelButton = NO;
}