简体   繁体   中英

When Clicking on an UISearchController, having it navigate to a new UIView Pragmatically Swift3

With the typical UISearchController, it only shows another view controller when you actually hit search. I am attempting to get another UIView to appear as soon as you click on the search bar. Any thoughts on how this could be done completely Pragmatically? I assume it can be accomplished by calling a function when UISearchController.active == true, but have yet to figure it out.

Apps that implement this sort of search function include the Ebay app and Instgram.

UISearchController has a property called searchBar. That's a UISearchBar. UISearchBar has a delegate property that should conform to the UISearchBarDelegate protocol. In that protocol there's a method searchBarShouldBeginEditing that will be called when the user begins editing in the search field. See:

Apple's documentation for searchBarShouldBeginEditing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM