Добавить UISearchBarDelegate
методы протокола для запуска метода протокола панели поиска;
class ViewController: UIViewController, UISearchBarDelegate, UIWebViewDelegate {
override func viewDidLoad() {
SearchBar.delegate = self
webview.delegate = self // connect your webview in storyboard
}
// MARK: - UISearchView Delegates
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
}
func searchBarSearchButtonClicked(searchbar: UISearchBar) {
// call your function here
let searchText = searchbar.text!
let url = URL (string: searchText)
let requestObj = URLRequest(url: url!)
webView.loadRequest(requestObj)
}
}