美文网首页
iOS 获取UIWebView上面的按钮点击事件

iOS 获取UIWebView上面的按钮点击事件

作者: 紫云夕月 | 来源:发表于2016-08-30 15:48 被阅读499次

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

if ([request.mainDocumentURL.relativePath isEqualToString:@"/alert"]) {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"本地代码执行" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];

[alert show];

return false;  //执行本地代码,返回false不让网页读取网络资源

}

return true;  //为yes加载内容,否则不

}

相关文章

网友评论

      本文标题:iOS 获取UIWebView上面的按钮点击事件

      本文链接:https://www.haomeiwen.com/subject/agofettx.html