- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
在我的 tvOS 应用程序中,我有一个搜索页面,顶部有一个 Search Bar
,下面有一个 Table View
,其中包含最终的结果列表。
当我们关注 searchBar
并且用户按下 Siri 的声音时,结果将插入到搜索栏中(如预期的那样)。但是,当用户向下滚动结果而无法找到他们要查找的内容时,他们必须向上滚动(一直向上滚动)到 searchBar
才能再次使用 Siri。
如果用户在 searchBar
不在焦点上时尝试使用 Siri,则全局 Siri 会开始在不同的应用程序中寻找结果(这不是我想要的)
如何在Search Page上设置searchBar为Siri的全局焦点?
老实说,我不知道该怎么做..
在 AppDelegate.swift 中调用一个函数来创建搜索 View Controller 并将其添加到标签栏 Controller 。
我曾考虑过尝试使用 preferedFocusView,但在阅读了文档后,我怀疑这是否可行。
func configueSearchController() -> UIViewController {
let storyboard = UIStoryboard(name: "Search", bundle: nil)
guard let searchResultsController = storyboard.instantiateViewController(withIdentifier: SearchViewController.storyboardIdentifier) as? SearchViewController else {
fatalError("Unable to instatiate a SearchResultViewController from the storyboard.")
}
/*
Create a UISearchController, passing the `searchResultsController` to
use to display search results.
*/
let searchController = UISearchController(searchResultsController: searchResultsController)
searchController.searchResultsUpdater = searchResultsController
searchController.searchBar.placeholder = NSLocalizedString("Enter keyword (e.g. Gastric Bypass)", comment: "")
searchController.view.backgroundColor = Constants.Color.backgroundcolor
searchController.searchBar.keyboardAppearance = UIKeyboardAppearance.dark
searchController.searchBar.tintColor = Constants.Color.backgroundcolor
searchController.searchBar.backgroundColor = Constants.Color.backgroundSearchBarColor
searchController.searchBar.setTextColor(color: .white)
searchController.hidesNavigationBarDuringPresentation = false
searchController.obscuresBackgroundDuringPresentation = true
searchController.searchBar.searchBarStyle = .minimal
searchController.searchBar.sizeToFit()
searchController.searchBar.focus
//TODO: Check if this works
searchController.searchBar.accessibilityLanguage = "en"
//searchResultsController.tableView.tableHeaderView = searchController.searchBar
// Contain the `UISearchController` in a `UISearchContainerViewController`.
let searchContainer: UISearchContainerViewController = UISearchContainerViewController(searchController: searchController)
// Finally contain the `UISearchContainerViewController` in a `UINavigationController`.
let searchNavigationController = UINavigationController(rootViewController: searchContainer)
searchNavigationController.navigationBar.isTranslucent = true
searchNavigationController.navigationBar.tintColor = Constants.Color.backgroundcolor
searchNavigationController.tabBarItem.title = "Search"
return searchNavigationController
}
最佳答案
关于swift - 如何在搜索页面上将searchBar设置为Siri的全局焦点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41961060/
我的 SearchFragment 是另外两个 Fragment 的宿主 Fragment:SearchUsersFragment 和 SearchEventsFragment。我的组织方式是 Tab
tableView.tableHeaderView = UISearchDisplayController.searchBar;并调用 setContentInset: ; 当我滚动表格时,没有绘制
我一直在努力寻找答案,但也许我没有正确地询问谷歌,所以它是这样的:我的 Android 应用程序中有一个搜索 View ,其中有顶部菜单项作为搜索输入,等等。我点击放大镜,然后文本字段变为可编辑的搜索
我已经设置了 UISearchBar 的东西。但我收到错误消息。 Cannot assign value of type '[cellData]' to type '[String]' 这是代码 st
我正在疯狂地尝试让我的 IOS 搜索栏在 Iphone 上工作。我从远程服务器访问数据并填充内容文件。然后我做了一个过滤器,它创建了一个过滤后的内容文件。然后我执行 [self.tableView r
我有一个 tableView,其中填充了一个 String 类型的数组。字符串中的某些单词包含连字符 (-)。我知道我可以过滤一个 tableView 并在需要时让它删除这个字符。是否可以在搜索过程中
我有一个带有 SegmentedControl、UITableView 和 UISearchController 的 UIViewController。 SegmentedControl 位于主视图的
当我像这样将 searchBar 对象调用到 UISearchBar 委托(delegate)方法中时,它工作正常: -(void)searchBarSearchButtonClicked:(UISe
我的 SearchBar 有这段代码可以更改我的收藏 View : extension ProductsCollectionViewController : UISearchControllerDel
只是一些后见之明,让您了解我的问题。我目前正在为我在设备上保存了 GuestList CoreData 的事件编写 iOS 应用程序。 在 viewDidLoad 上,它会获取 coredata 对象
我正在按照本教程了解如何启动和运行 searchBar。 教程: https://www.raywenderlich.com/113772/uisearchcontroller-tutorial 我完
我正在尝试对我的应用实现搜索。以前看了好几个教程,都推荐把Search Bar放到Table Header: self.tableView.tableHeaderView = self.searchC
我的搜索栏有默认的灰色文本,但我希望它是白色文本。我无法弄清楚如何使用 swift 来更改范围栏文本颜色,而且您无法从 Storyboard 中执行此操作。我找到的最接近的是 searchBarOut
我刚刚在我的程序中添加了一个 ui 搜索栏,每次我重新运行该程序时,我都会收到错误消息 -[一般] 与守护程序的连接无效尽管如此,我的应用程序仍能完美运行,而且我似乎无法分辨出哪里出了问题。 有谁知道
我又会显得很傻了,但这总比发疯好!这是我的问题。我有一个 UISearchBar,其中有一个我想隐藏的scopeBar。我这样做: searchBar.showsScopeBar = NO; 我也调用
需要帮助来更正此代码。 我有一个带有餐厅名称和地址的核心数据应用程序,有一个搜索栏,它正在运行。我要添加的是一个 Index 和一个 IndexTitle,如下图(箭头)所示。 非常欢迎任何帮助。提前
我正在使用 SearchDisplayController 并希望将样式或色调应用于 searchBar。 但我注意到 SearchDisplayController 更改了我的 searchBar
我当前使用searchBar,我将左侧图标更改为自定义 UIImageView。当按下按钮时我想将其改回原来的搜索图标。 //my custom search iconBar searchBar.se
我在我的电视应用程序中使用自定义搜索屏幕,我的问题是我无法在启动 fragment 时将焦点设置在 SearchBar View 上。我尝试了以下方法: mSearchBar.setFocusable
我想在输入 edittext 内容的 ListView 行中搜索相关的 Row。 如何在 Listview 中获取行..请给我示例代码.. 谢谢 最佳答案 我假设您想根据您键入的 edittext 值
我是一名优秀的程序员,十分优秀!