我在加载URL时遇到了非常小的问题UIWebView
。我有一个UIButton
,单击它时,我添加了UIView
其中包含UIWebView
, UIButton
& Title bar
。使用的代码如下 -
[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
不会加载URL
我在 object 中传递的内容objWine.strOnlineURL
。如果我单击后退按钮并再次单击按钮以加载,它将URL
进入. 如果有人知道解决方案,请帮助我。- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
UIWebView