- (BOOL)webview:不在目标c xcode中运行

时间:2013-07-09 09:10:54

标签: objective-c webview

我试图让它运行...我已经放入了NSLog,但是当我更改页面时,调试器中没有任何内容。

这是我的代码:

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

1 个答案:

答案 0 :(得分:1)

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

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

即。 webView,而非webview