UIWebView Delegate Methods not Working [closed]

喜你入骨 提交于 2019-12-02 07:42:20
Arjun

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

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

remove that extra http

    {
       self.myWeview.delegate = self;
       NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
       NSURLRequest *request = [NSURLRequest requestWithURL:url];
       [myWebView loadRequest:request];
    }
Rohan

You have made the mistake in calling the URL ...

Try this :

NSURL *url = [NSURL URLWithString:@"http://www.google.com"];

Use this code in your viewcontroller.h file

@interface ViewController : UIViewController<UIWebViewDelegate>

set delegate to self then you need to implement the delegate

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
   return YES;
}

and also don't forget to confirm the protocol in .h file like this

@interface YourViewController : UIViewController<UIWebViewDelegate>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!