我正在尝试让它运行...我已经放入了 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;
}