2
votes

If there's a better way to accomplish this feel free to give me hints.

What I'm trying to do is open up a search controller from a UITableViewCell select event (it's for address input). I've accomplished by creating a whole new view controller in storyboard, etc. but this seems needless heavy handed for just presenting an address lookup.

I tried instantiating a UISearchContainerViewController also but I can't for the life of me figure out how to make it "work". It presents "black".

Edit: I've found that despite what the docs say about wrapping the UISearchController in a UISearchContainerViewController presenting the UISearchController directly works fine.

https://developer.apple.com/documentation/uikit/uisearchcontroller

Although a UISearchController object is a view controller, you should never present it directly from your interface. If you want to present the search results interface explicitly, wrap your search controller in a UISearchContainerViewController object and present that object instead.

1

1 Answers

1
votes

I also was working on this and all I found is - you can present you serchcontroller like this:

self.present(searchcontroller, animated: true, completion: nil)

I know that it's not allowed by apple but it can solve your task.

Also I suppose you can just call becomeFiestResponder on searchBar. If it's not working - try to call becomeFiestResponder on TextField which is inside searchBar.