0

This is code about my search in the app.

    self.searchController = UISearchController(searchResultsController:  nil)
    self.searchController.searchResultsUpdater = self
    self.searchController.delegate = self
    self.searchController.searchBar.delegate = self
    self.searchController.hidesNavigationBarDuringPresentation = false
    self.searchController.dimsBackgroundDuringPresentation = true
    self.searchController.searchBar.tintColor = UIColor.gray
    self.navigationItem.titleView = searchController.searchBar
    self.definesPresentationContext = true

I want to my search bar auto active when the page appear?

Dose anyone has ideas to do that? You can look on my image to make clear.

enter image description here

rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

0

Try to add to viewWillAppear self.searchController.searchBar.becomeFirstResponder()

AntiVIRUZ
  • 342
  • 1
  • 14