我正在尝试向搜索栏发送地址,但是什么也没发生:
override func viewDidLoad() {
if let url = URL(string: "https://www.google.com"){
let requestObj = URLRequest(url: url)
Webview.loadRequest(requestObj)
}
SearchBar.text = "http://"
}
func searchBarSearchButtonClicked(searchbar: UISearchBar) {
searchbar.resignFirstResponder()
let text = SearchBar.text
let url = NSURL(string: text!)
let urlRequest:URLRequest = URLRequest(url: url! as URL)
let request = NSURLRequest(URL: url! as URL)
Webview.loadRequest(urlRequest)
}
}
答案 0 :(得分:0)
您的searchBar委托获得了错误的函数签名。
func searchBarSearchButtonClicked(_ searchBar: UISearchBar){
// func searchBarSearchButtonClicked(searchbar: UISearchBar) {
因此您的搜索无效