0
私は奇妙な問題を抱えています。アプリを最初に読み込むと、何回タップしても検索バーにテキストを入力できません。検索バーはナビゲーションバーに入れ子になっています。ナビゲーションバーのUISearchBarはテキストを入力できません
私のアプリでもタブバーを使用しています。タブを切り替えると、検索バーでタブに戻り、テキストを入力できます。これは何が原因ですか?
検索バーのための相続人コード:
func setupSearchBar(){
let locationSearchTable = storyboard!.instantiateViewController(withIdentifier: "LocationSearchTable") as! LocationSearchTableViewController
resultSearchController = UISearchController(searchResultsController: locationSearchTable)
resultSearchController?.searchResultsUpdater = locationSearchTable
searchBar = resultSearchController!.searchBar
searchBar.sizeToFit()
searchBar.placeholder = "Location"
searchBar.isTranslucent = true
searchBar.isUserInteractionEnabled = true
for subView in searchBar.subviews{
for subsubView in subView.subviews{
if let textField = subsubView as? UITextField{
var currentTextFieldBounds = textField.bounds
currentTextFieldBounds.size.height = 40.0
textField.bounds = currentTextFieldBounds
textField.borderStyle = UITextBorderStyle.none
textField.textAlignment = NSTextAlignment.left
textField.font = UIFont(name: "System", size: 25.0)
textField.textColor = theme?.textColour
}
}
}
self.navigationController?.navigationBar.setBarColour(colour: (theme?.tabBarColour)!, tint: (theme?.textColour)!)
navigationItem.titleView = resultSearchController?.searchBar
navigationItem.titleView?.bringSubview(toFront: (resultSearchController?.searchBar)!)
searchBar.delegate = self
searchBar.showsSearchResultsButton = true
searchBar.setImage(#imageLiteral(resourceName: "location_icon.png"), for: UISearchBarIcon.resultsList, state: UIControlState.normal)
resultSearchController?.hidesNavigationBarDuringPresentation = false
resultSearchController?.dimsBackgroundDuringPresentation = true
definesPresentationContext = true
locationSearchTable.mapView = mapView
locationSearchTable.handleMapSearchDelegate = self
}
"テキストを入力できません"とはどういう意味ですか、キーボードが表示されていないか、テキストボックスに何も入力できません。 – Lawliet
キーボードがまったく表示されません。タブを変更した後にのみ。私は少しコードを投稿します、私は現在、現時点では家から出ています。 –
Plzスクリーンショットを追加&詳細...問題が見つからない場合 –