UIWebView委托方法不起作用 [英] UIWebView Delegate Methods not Working
问题描述
**当我使用 self.myWeview.delegate = self
时,
UIWebView
无法加载 URL
in UIWebView
...
但如果我将其设置为 self。 myWeview.delegate = nil
,
然后方法(委托)无法加载,但 URL
加载
这是代码:---
**When I Use self.myWeview.delegate = self
,
UIWebView
can not load URL
in UIWebView
...
But If I set it to self.myWeview.delegate = nil
,
then methods(delegate) can't load but URL
is load
this is the code:---
{
self.myWeview.delegate = nil;
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[myWebView loadRequest:request];
}
这工作正常,但无法调用委托方法。
This is working fine but couldn't called delegate methods.
另一方面
{
self.myWeview.delegate = self;
NSURL *url = [NSURL URLWithString:@"http:http://www.google.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[myWebView loadRequest:request];
}
无法加载网址
但调用委托方法
It Couldn't load URL
but calls the delegate methods
推荐答案
最后我通过大量实验得到了答案,如果我们不使用这种方法
Finally I got my answer by lot of experiment,if we not using this method
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
除了所有方法在UIwebViewDelegate中正常工作
except that all methods are working fine in UIwebViewDelegate
1. -(void)webViewDidFinishLoad:(UIWebView *)webView
2. -(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
3. -(void)webViewDidStartLoad:(UIWebView *)webView
这篇关于UIWebView委托方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!