我需要從UIWebView中獲取一個URL並將其放入地址欄。我使用這個代碼,但它根本不起作用。將webview網址放在地址欄中
- (void)webViewDidStartLoad:(UIWebView *)webView2 shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType{
NSURL *URL = [request URL];
[webAdress2 setText:[URL absoluteString]];
}
請幫忙!
你的代碼似乎對我來說,錯誤必須在別處。 –
你需要提供更多關於webAdress2的信息,它是什麼,你在哪裏創建它等 – jbat100
我設置webAdress2和webView2像這樣 - NSString * settingValue2 = [[NSUserDefaults standardUserDefaults] stringForKey:@「url2」]; NSURL * urlx2 = [NSURL URLWithString:[NSString stringWithFormat:@「%@」,settingValue2]]; NSURLRequest * request2 = [NSURLRequest requestWithURL:urlx2]; [webView2 loadRequest:request2]; [webAdress2 setText:settingValue2]; – nik1004