0

我正在尝试让它运行...我已经放入了 NSLogs,但是当我更改页面时,调试器中没有出现任何内容。

这是我的代码:

#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.
}

下面的这部分似乎没有运行(调试器中没有出现日志!)

- (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;
}
4

1 回答 1

1

检查委托方法的大小写;它应该是:

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

webView,不是webview

于 2013-07-09T09:34:52.247 回答