我正在嘗試構建簡單的網絡瀏覽器。網頁瀏覽器本身工作得很好,但是當我嘗試在搜索欄中搜索網址時,我無法返回鍵盤來打開網站。我怎樣才能解決這個問題?搜索酒吧和網絡視圖
@IBOutlet weak var searchBar: UISearchBar!
@IBOutlet weak var webView: UIWebView!
func searchBarSearchButtonClicked(searchBar: UISearchBar) {
searchBar.resignFirstResponder()
let text = searchBar.text
let urlSB = NSURL(string: text!)
let reqSB = NSURLRequest(url:urlSB! as URL)
self.webView!.loadRequest(reqSB as URLRequest)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let url = NSURL(string: "https://www.google.com")
let req = NSURLRequest(url:url! as URL)
self.webView!.loadRequest(req as URLRequest)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
請問當你按下搜索程序崩潰?或者它什麼都不做? –
沒有任何事情發生 – user245935