將UISearchController
與UIAlertController
組合在tvOS上有UITextField
時出現問題。當試圖在tvOS上輸入文本時,UISearchController與UIAlertController問題結合
我有一個UIButton
,它呈現UISearchController
與UISearchResultsController
。
不知何故輸入視圖(鍵盤畫面)沒有顯示在屏幕上,從下面的UIAlertController
代碼與測試項目鏈路,而問題的視頻演示擊中UITextField
時,也是如此。
ViewController.swift - 從這裏我展示searchController
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonAction(_ sender: UIButton) {
let searchResultsController = storyboard?.instantiateViewController(withIdentifier:"SearchResultsViewController")
let searchController = UISearchController(searchResultsController: searchResultsController)
show(searchController, sender: self)
}
}
SearchResultsViewController.swift - 當敲擊從collectionView
細胞我提出了一個UIAlertController
用UITextField
。攻絲對文本字段將不顯示輸入視圖(鍵盤畫面)
class SearchResultsViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UISearchResultsUpdating {
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func updateSearchResults(for searchController: UISearchController) {
collectionView.reloadData()
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
return collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let ac = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert)
ac.addTextField { (textfield) in
textfield.placeholder = "Action here doen't show the keyboard to input text..."
}
let ok = UIAlertAction(title: "Ok", style: .default) { (action) in
print(ac.textFields?.first?.text)
}
ac.addAction(ok)
present(ac, animated: true, completion: nil)
}
}
視頻鏈接here
測試項目鏈接here
任何想法,我做錯了什麼?
感謝