我遇到了问题:
如何检测何时在UIWebView中播放超链接?
@synthesize webView = webView;
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
webView.delegate = self;
webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
NSString* htmlContentString = [NSString stringWithFormat:
@"<!DOCTYPE html>\
<html>\
<head>\
<meta charset=\"utf-8\">\
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=0\" />\
<title>Titulo</title>\
</head>\
<body style=\"margin:0;padding:0;font-family:'Helvetica'\">\
</body>\
</html>"];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
webView.allowsInlineMediaPlayback = YES;
webView.mediaPlaybackRequiresUserAction = NO;
[webView loadHTMLString:htmlContentString baseURL:baseURL];
[self.view addSubview:webView];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
[[UIApplication sharedApplication] openURL:request.URL];
NSLog(@"ok!");
return false;
}
return true;
}
我用变量查看并将它们打印为html,但我应该使用StartLoadWithRequest函数检测不到任何内容。
我正在使用委托uiwevbiew。
我应该用javascript做什么?
问候。