我有一个 web 视图,我想在其中调用 Obj-C 代码,我这样做就像在thisTutorial
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSString *absoluteUrl = [request.URL absoluteString];
NSLog(@"STRING: %@",absoluteUrl);//prints out didTap://button1
NSString *sayHello = @"didTap://button1";
if ([sayHello isEqualToString: absoluteUrl]) {
[self sayHello];
return NO;
}
return YES;
}
然而[self sayHello]
从未被调用。有人知道为什么吗?