Ios 如何禁用或隐藏搜索栏中的范围按钮?

Ios 如何禁用或隐藏搜索栏中的范围按钮?,ios,swift,uisearchcontroller,Ios,Swift,Uisearchcontroller,我是ios新手,我使用的是Xcode 7和swift 2,我用我的tableViewController实现了一个搜索栏控件,如下所示: searchController.searchResultsUpdater = self searchController.searchBar.delegate = self definesPresentationContext = false searchController.dimsBackgroundDuringPresentation = false

我是ios新手,我使用的是Xcode 7和swift 2,我用我的
tableViewController
实现了一个搜索栏控件,如下所示:

searchController.searchResultsUpdater = self
searchController.searchBar.delegate = self
definesPresentationContext = false
searchController.dimsBackgroundDuringPresentation = false

// Setup the Scope Bar
searchController.searchBar.scopeButtonTitles = ["All", "Chocolate"]
searchController.searchBar.showsScopeBar = false
searchController.searchBar.searchBarStyle = .Default
tableView.tableHeaderView = searchController.searchBar
但我不想在这种情况下的范围按钮。我怎么能把它们藏起来

注意,这不适用于我:

searchController.searchBar.showsScopeBar = false

情节提要

通过故事板使用搜索显示控制器,转到搜索栏属性检查器,如果选中,则取消选中“显示范围栏”。如果有,则删除范围标题

以编程方式

如果以编程方式使用“搜索显示控制器”,则必须删除此部分,但不会显示范围栏

searchController.searchBar.scopeButtonTitles = ["All", "Chocolate"]
searchController.searchBar.showsScopeBar = false
searchController.searchBar.scopeButtonTitles = nil

将ScopeButtonTiles设置为nil也将删除范围栏中的按钮

searchController.searchBar.scopeButtonTitles = ["All", "Chocolate"]
searchController.searchBar.showsScopeBar = false
searchController.searchBar.scopeButtonTitles = nil

情节提要

通过故事板使用搜索显示控制器,转到搜索栏属性检查器,如果选中,则取消选中“显示范围栏”。如果有,则删除范围标题

以编程方式

如果以编程方式使用“搜索显示控制器”,则必须删除此部分,但不会显示范围栏

searchController.searchBar.scopeButtonTitles = ["All", "Chocolate"]
searchController.searchBar.showsScopeBar = false
searchController.searchBar.scopeButtonTitles = nil

将ScopeButtonTiles设置为nil也将删除范围栏中的按钮

searchController.searchBar.scopeButtonTitles = ["All", "Chocolate"]
searchController.searchBar.showsScopeBar = false
searchController.searchBar.scopeButtonTitles = nil

scopeButtonTitles使之变为零,如searchController.searchBar.scopeButtonTitles=nil感谢您的帮助@Vinodh答案已更新,谢谢。scopeButtonTitles将此searchController设置为零。searchBar.scopeButtonTitles=nil谢谢您的帮助@Vinodh答案更新,谢谢。