ios原生与h5交互需要注意什么
1个回答
展开全部
你得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;
}
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;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询