我正在寫一個iPhone應用程序,並且有加載,看起來像這樣的URL一個UIWebView:更改URL並重新加載UIWebView?
http://www.example.com/search?query=dog
網站知道使用query=
後什麼來作爲網站上的搜索詞。在這種情況下,「狗」。
應用程序中的WebView上方有一個搜索欄,用戶可以使用該搜索欄搜索其他內容。因此,如果用戶鍵入「貓」到搜索欄和點擊搜索,我要的網址改成這樣:
http://www.example.com/search?query=cat
我不能讓它工作,雖然。它不斷加載頁面,就像我在尋找狗。任何人都可以啓發我如何更改URL並刷新WebView?以下是我的代碼的樣子:
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
urlString = @"http://www.example.com/search?query=%i", searchBar.text;
[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
[self.myWebView reload];
[searchBar setShowsCancelButton:NO animated:YES];
}
你說得對您的網址。這對我來說很愚蠢。謝謝。 – rottendevice 2011-03-17 17:47:49