如何禁用或隐藏搜索栏中的范围按钮?
How to disable or hide the scope buttons in searchbar?
我是 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
故事板
通过情节提要使用搜索显示控制器,转到搜索栏属性检查器并取消选中 "Shows Scope Bar"(如果有)checked.and 删除范围标题(如果有)。
以编程方式
以编程方式使用 Search Display Controller 然后你必须删除这部分,将不会显示范围栏
searchController.searchBar.scopeButtonTitles = ["All", "Chocolate"]
searchController.searchBar.showsScopeBar = false
或
使 scopeButtonTitles 为 nil 也会删除范围栏中的按钮
searchController.searchBar.scopeButtonTitles = nil
我是 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
故事板
通过情节提要使用搜索显示控制器,转到搜索栏属性检查器并取消选中 "Shows Scope Bar"(如果有)checked.and 删除范围标题(如果有)。
以编程方式
以编程方式使用 Search Display Controller 然后你必须删除这部分,将不会显示范围栏
searchController.searchBar.scopeButtonTitles = ["All", "Chocolate"]
searchController.searchBar.showsScopeBar = false
或
使 scopeButtonTitles 为 nil 也会删除范围栏中的按钮
searchController.searchBar.scopeButtonTitles = nil