0

UISearchControllerUIAlertControllerとを組み合わせて、tvOSにUITextFieldが含まれていると問題が発生します。tvOSにテキストを入力しようとすると、UISearchControllerとUIAlertControllerの問題が発生する

私はをUISearchResultsControllerと表しています。これはUIButtonです。問題のテストプロジェクトのリンク、およびビデオデモと同様に、以下UIAlertController

コードからUITextFieldを打つとき

は、どういうわけか、入力ビュー(キーボード画面)は、画面上に表示されていません。

ViewController.swift - 私はUITextFieldUIAlertControllerを提示collectionViewからセルをタップする - ここから私は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を示しました。入力ビューが表示されませんそのテキストフィールドをタップ(キーボード画面)

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

すべてのアイデア、私が何か間違ったことをやっていますか?私はUISearchControllerUISearchResultsControllerで働いていたとき

おかげ

答えて

0

は、私は同様の問題を抱えていました。私はハイブリッドアプリケーションへの移行によってそれを解決しました。 searchTemplateで検索を実装し、ユーザーが何かを検索する必要があるときに表示します。しかし、最も簡単な方法を試すこともできます。UIAlertControllerをTVMLポップアップとして実装することができます(これを行うにはformTemplateという項目を使用できます)。

関連する問題