smj2393
smj2393

Reputation: 1957

- (BOOL)webview: doesn't run in objective c xcode

I am trying to get this to run... I have put in NSLogs, but nothing appears in the debugger when I change page.

Here is my code:

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize webview;

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.webview.delegate = self;
    NSString *path = [[NSBundle mainBundle] pathForResource:@"menu" ofType:@"html"     inDirectory:@"pages"];
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    [self.webview loadRequest:request];
    NSLog(@"%@",[[request URL] absoluteString]); //this log appears when the ipad simulator starts
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

This section below doesn't seem to run (no log appears in the debugger!)

- (BOOL)webview:(UIWebView*)aWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType

{
    NSLog(@"%@",[[request URL] absoluteString]);
    NSString *absoluteUrl = [[request URL] absoluteString];
    if ([absoluteUrl isEqualToString:@"didtap://button1"]) {

        NSLog(@"Button tapped");
        return NO;
    }
    return YES;
}

Upvotes: 0

Views: 162

Answers (1)

trojanfoe
trojanfoe

Reputation: 122391

Check the capitalization of your delegate method; it should be:

- (BOOL)webView:(UIWebView*)aWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType

i.e. webView, not webview.

Upvotes: 1

Related Questions