tvOS:一种让 UISearchController 不显示为按钮的方法?
tvOS: A way to have UISearchController not appear as a button?
这个代码
var searchController: UISearchController!
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
view.addSubview(searchController.searchBar)
getItems()
}
产生这个:
Screeshot1
请注意,searchBar 显示为卡在左上角的按钮(因为这是一个选项卡式应用程序,它在首次出现时出现在选项卡栏下方。"Button" 按钮在那里接收焦点以进行测试) .
这是按下按钮后的样子:Screenshot2
第二张图片显示了我希望搜索选项卡打开时的外观,以及我认为它在 tvOS 中的外观。
如何让 searchController 像第二个屏幕截图中那样显示?许多 tvOS 应用程序都这样做,所以我知道这一定是可能的。我已经仔细阅读了文档,但我一定是遗漏了什么。
一个相关的问题是下面的 collectionView 不会从 searchController 获取焦点。必须使用远程菜单按钮返回才能使 collectionView 聚焦。
当视图出现时,如何让 searchController 像第二个屏幕截图中那样出现?
如何让 collectionView 从 searchController 获得焦点而不必返回到标签栏?
我终于 运行 跨过了 tvOS 开发者库中的这段话
All of the iOS first responder mechanisms work on tvOS. This allows
developers to present a UI, visible or hidden, and then make one of
the text fields the first responder by calling the
becomeFirstResponder method on it. This action causes the text field
to put up the keyboard UI without the user having to navigate to a
text field and click on it.
所以,添加
searchController.searchBar.becomeFirstResponder()
显示我希望用户开始使用的内联键盘。但是,在焦点引擎再次启动之前,必须按下遥控器上的菜单按钮。菜单按钮还将键盘和搜索栏 returns 关闭到其按钮状态。
这是对我第一个问题的回答。对第二个还是一头雾水。
这个代码
var searchController: UISearchController!
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
view.addSubview(searchController.searchBar)
getItems()
}
产生这个: Screeshot1
请注意,searchBar 显示为卡在左上角的按钮(因为这是一个选项卡式应用程序,它在首次出现时出现在选项卡栏下方。"Button" 按钮在那里接收焦点以进行测试) .
这是按下按钮后的样子:Screenshot2
第二张图片显示了我希望搜索选项卡打开时的外观,以及我认为它在 tvOS 中的外观。
如何让 searchController 像第二个屏幕截图中那样显示?许多 tvOS 应用程序都这样做,所以我知道这一定是可能的。我已经仔细阅读了文档,但我一定是遗漏了什么。
一个相关的问题是下面的 collectionView 不会从 searchController 获取焦点。必须使用远程菜单按钮返回才能使 collectionView 聚焦。
当视图出现时,如何让 searchController 像第二个屏幕截图中那样出现?
如何让 collectionView 从 searchController 获得焦点而不必返回到标签栏?
我终于 运行 跨过了 tvOS 开发者库中的这段话
All of the iOS first responder mechanisms work on tvOS. This allows developers to present a UI, visible or hidden, and then make one of the text fields the first responder by calling the becomeFirstResponder method on it. This action causes the text field to put up the keyboard UI without the user having to navigate to a text field and click on it.
所以,添加
searchController.searchBar.becomeFirstResponder()
显示我希望用户开始使用的内联键盘。但是,在焦点引擎再次启动之前,必须按下遥控器上的菜单按钮。菜单按钮还将键盘和搜索栏 returns 关闭到其按钮状态。
这是对我第一个问题的回答。对第二个还是一头雾水。