为什么webview截获不到h5的消息 ios
发布网友
发布时间:2022-05-16 16:41
我来回答
共1个回答
热心网友
时间:2023-11-01 09:52
h5界面按钮点击实现
window.location.href = "协议名:其啥啥";
window.location.href = "ios:back";
webview代理
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSString *requestString = [[request URL] absoluteString];
requestString = [requestString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
if( navigationType == UIWebViewNavigationTypeOther ) {
if ([requestString hasPrefix:@"ios:"]) {
//始处理逻辑想跳转跳转 自控制呗
//比我处理跳webview
[self.navigationController popViewControllerAnimated:YES];
return NO;
}
}
return YES;
}
b