I am using https://www.raywenderlich.com/4363809-uisearchcontroller-tutorial-getting-started as based project.
To make UISearchController
hidden initially during app startup, I have move the following line of code, from viewDidLoad
to viewWillAppear
.
navigationItem.searchController = searchController
In order to start search feature, user will need to
- "Pull down"
UITableView
to makeUISearchController
visible. - Tab on the
UISearchController
‘s search bar so that the search bar is in focus.
Here’s how it looks like
However, from UX point of view, user (Especially first time iPhone user) cannot discover such search feature easily.
We also do NOT want to display the search bar when the screen shows for the first time. It occupies screen space, and search feature is not a frequent accessed feature.
To make such search feature easy discoverable, we would like to provide a bar button item (with magnifying-glass icon) at top right. If user taps on it, the app will perform step 1 and step 2 programmatically.
May I know, how can I show, then focus UISearchController programmatically?
2
Answers
if I catch it correctly what did you say:
You can try manually updating
UISearchController.isActive
to force launch the search interface.