4

I want to use UIWebViewDelegate methods. I set its delegate to self but still not working

-(void)webViewDidStartLoad:(UIWebView *)webView {
    NSLog(@"Load view");    
}   

-(void)webViewDidFinishLoad:(UIWebView *)webView {
    NSLog(@"Finish View");   
}


-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    NSLog(@"Error in loading: %@", [error description]);
}
Wasim Ahmad
  • 71
  • 1
  • 8
  • What is not working exactly? – jbkkd Dec 25 '14 at 11:45
  • none of these methods get called... not giving error as well @jbkkd – Wasim Ahmad Dec 25 '14 at 11:46
  • @WasimAhmad You Set Delegate in Xib File? –  Dec 25 '14 at 11:47
  • Where do you set `delegate` to `self`? Please show that as well, if it's in code. – ravron Dec 25 '14 at 11:47
  • i set the delegate in viewcontroller.m file.. @iOSDeveloper – Wasim Ahmad Dec 25 '14 at 11:49
  • @WasimAhmad also Connect WebView Delegate to Your File Owner if you Use WebView Controller in Xib file.and Pest Your Some Code for Your WebView. –  Dec 25 '14 at 11:50
  • @RileyAvron - (void)viewDidLoad { [super viewDidLoad]; self.viewWeb.delegate = self; NSString *fullURL = @"http://www.wherewomenmeet.org"; NSURL *url = [NSURL URLWithString:fullURL]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [_viewWeb loadRequest:requestObj]; } – Wasim Ahmad Dec 25 '14 at 11:52
  • i don't use any xib file rather i use .storyboard.. @iOSDeveloper – Wasim Ahmad Dec 25 '14 at 11:53
  • @WasimAhmad Connect Your Webview Delgate to your View Controller in StoryBoard and Also You Set in You .h file ? –  Dec 25 '14 at 11:57
  • i have added to .h file, but how can i connect web view delegate to storyboard @iOSDeveloper – Wasim Ahmad Dec 25 '14 at 12:00
  • 2
    @WasimAhmad Why Not When You Click On Your WebView in StoryBoard and Show in Connection Inspector it Shows Delegate that Connect it to Your View Controller. also Show this link http://stackoverflow.com/questions/4342006/set-a-delegate-for-uiwebview –  Dec 25 '14 at 12:03
  • @WasimAhmad try following instructions from this article: http://cagt.bu.edu/w/images/d/d1/UIWebview_example_code.txt there is the comment section "In the .xib file", go to your storyboard, click on your View and follow the instructions described in that comment. That should help. – AzaFromKaza Dec 25 '14 at 12:04
  • @WasimAhmad Can you Get Solution? –  Dec 25 '14 at 12:08
  • i am trying it, and letting you know then.. thanks @iOSDeveloper – Wasim Ahmad Dec 25 '14 at 12:10

1 Answers1

1

Do not write anything in viewDidLoad. Try putting webview related code viewDidAppear or any custom method. Cross check if your webview is connected properly in storyboard.

devios1
  • 36,899
  • 45
  • 162
  • 260
Bizcharts
  • 44
  • 2
  • its now working..!! i connect delegate to my viewcontroller. what i was doing wrong is, i was calling uiwebviewdelegate methods in myappdelegate.m file, now i added these methods in viewload (); . it worked for me thanks every one for help. – Wasim Ahmad Dec 25 '14 at 12:59
  • gr8.. :) Accept the answer it was helpful to you. – Bizcharts Dec 25 '14 at 13:06