2016-08-18 2 views
1

J'utilise le contrôleur bar UISearch enter image description herela barre de recherche disparaissent après la presse recherche

après que je presse sur elle disparaître comme ce enter image description here

mon code:

let searchController = UISearchController(searchResultsController: nil) 


override func viewDidLoad() { 
    super.viewDidLoad() 

    // MARK: - Search 
    searchController.searchBar.delegate = self 
    navigationItem.titleView = searchController.searchBar 

} 
func searchBarTextDidBeginEditing(searchBar: UISearchBar) { 
presentViewController(searchController, animated: true, completion: nil) 

} 
+0

Pourquoi appelez-vous "presentViewController (SearchController, animé: true, achèvement: néant)" sur le texte a commencé à éditer ...? –

+1

@RoyK même Si je ne l'appelle pas j'ai le même problème – Sam

Répondre

1

essayer cette

self.searchController.hidesNavigationBarDuringPresentation = NO 
self.definesPresentationContext = NO 

ou utilisez cette

func willPresentSearchController(searchController: UISearchController)  { 
self.navigationController.navigationBar.translucent = true 
} 

func willDismissSearchController(searchController: UISearchController) { 
self.navigationController.navigationBar.translucent = false 
} 

pour une aide supplémentaire voir ce link

0

Essayez de définir cette propriété de Viewcontroller

self.definesPresentationContext = NO 
+0

Ne fonctionne pas ... – Sam