我在加載網址在UIWebView
時出現非常小的問題。 我有一個UIButton
,點擊它,我添加UIView
其中包含UIWebView
,UIButton
& Title bar
。使用代碼如下 -UIWebView不會加載網址
[self.view addSubview:vwOnline];
vwOnline.bounds = self.view.bounds;
//Load webview
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", objWine.strOnlineURL]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[wbvwOnline loadRequest:request];
- (void)webViewDidStartLoad:(UIWebView *)webView
{
//Show activity indicator
[indicator startAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
//Remove Activity indicator
[indicator stopAnimating];
[indicator removeFromSuperview];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
NSLog(@"Error - %@", error);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Find A Vino" message:@"Error while loading request." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
alert.tag = 1;
//Remove Activity indicator
[indicator stopAnimating];
[indicator removeFromSuperview];
}
通過上面的代碼做,最次UIWebView
不加載,我的對象objWine.strOnlineURL
通過URL
。如果我點擊後退按鈕&再次點擊按鈕加載URL
,它會進入- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
委託方式UIWebView
。 如果有人知道解決方案,那麼請幫助我。
是否objWine.strOnlineURL的內容絕對是一個有效的網址? – Blounty
是的內容是有效的,因爲如果我複製並粘貼包含在瀏覽器上,然後它在瀏覽器上打開該URL。 – Girish
什麼打印到NSLog(@「錯誤...? –