美文网首页
js与oc的交互

js与oc的交互

作者: 夏夏的一些事 | 来源:发表于2016-11-08 10:36 被阅读0次

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

{

//    NSLog(@"1---%@",request.mainDocumentURL.relativePath);

if([request.mainDocumentURL.relativePath hasPrefix:@"//data="])

{

/*  暂时没有参数要处理

NSString * json = [request.mainDocumentURL.relativePath stringByReplacingOccurrencesOfString:@"//data=" withString:@""];

NSDictionary * dic = [json JSONValue];

NSLog(@"2---%@",json);

*/

[self back];

return NO;

}

return YES;

}

    function toApp()     {         window.location = "http://toIOSApp://data={'data1':'aaa','data2':'bbb','data3':'ccc'}";     }

相关文章

网友评论

      本文标题:js与oc的交互

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