<tfoot id='RtG4B'></tfoot>
<legend id='RtG4B'><style id='RtG4B'><dir id='RtG4B'><q id='RtG4B'></q></dir></style></legend>
    • <bdo id='RtG4B'></bdo><ul id='RtG4B'></ul>
    <i id='RtG4B'><tr id='RtG4B'><dt id='RtG4B'><q id='RtG4B'><span id='RtG4B'><b id='RtG4B'><form id='RtG4B'><ins id='RtG4B'></ins><ul id='RtG4B'></ul><sub id='RtG4B'></sub></form><legend id='RtG4B'></legend><bdo id='RtG4B'><pre id='RtG4B'><center id='RtG4B'></center></pre></bdo></b><th id='RtG4B'></th></span></q></dt></tr></i><div id='RtG4B'><tfoot id='RtG4B'></tfoot><dl id='RtG4B'><fieldset id='RtG4B'></fieldset></dl></div>

  • <small id='RtG4B'></small><noframes id='RtG4B'>

        如何在 iphone 中使用 UIWebview 使图像地图可点击?

        时间:2023-10-22
          <tbody id='VIs7D'></tbody>

          • <bdo id='VIs7D'></bdo><ul id='VIs7D'></ul>

            <small id='VIs7D'></small><noframes id='VIs7D'>

                <tfoot id='VIs7D'></tfoot>
              1. <legend id='VIs7D'><style id='VIs7D'><dir id='VIs7D'><q id='VIs7D'></q></dir></style></legend>
                  <i id='VIs7D'><tr id='VIs7D'><dt id='VIs7D'><q id='VIs7D'><span id='VIs7D'><b id='VIs7D'><form id='VIs7D'><ins id='VIs7D'></ins><ul id='VIs7D'></ul><sub id='VIs7D'></sub></form><legend id='VIs7D'></legend><bdo id='VIs7D'><pre id='VIs7D'><center id='VIs7D'></center></pre></bdo></b><th id='VIs7D'></th></span></q></dt></tr></i><div id='VIs7D'><tfoot id='VIs7D'></tfoot><dl id='VIs7D'><fieldset id='VIs7D'></fieldset></dl></div>
                  本文介绍了如何在 iphone 中使用 UIWebview 使图像地图可点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在寻找如何从 HTML 到 iPHone 原生 obj-c 的 onclick 获取 'one' 和 'park' 字符串值(这是 UIwebview 上的 image_map 坐标可点击点).我已将代码用于获取字符串值,但它没有响应...请检查并帮助

                  I am looking how to get 'one' and 'park' string value (which is image_map coordinates clickable spot on UIwebview's) onclick from HTML to iPHone native obj-c. I have put the code to get string value but it is not responding...plz check and help

                  我用可能的答案更新了代码.如果图像地图和地图可点击表面更多,这将是复杂的.任何有关编码和解释的帮助和建议都将受到赞赏.提前致谢

                  I have updated code with possible answer. Which will be complicated if the image maps and map clickable surfaces are more. Any help and suggestion with coding and explaination on this are appreciated. thanks in advance

                  更新:*HTML 代码*

                  <html>
                  <body onload="anyFunction();">
                  <script language="javascript">
                  
                  function anyFunction(){
                  window.location='value';
                  }
                  
                  function callFromActivity(msg){
                  document.getElementById("circle").innerHTML = 'onclick';
                      }
                  </script> 
                  
                   <img src="map_new123.png" width="1500" height="731" border="0" usemap="#map" />
                   <a href="didTap://button1">
                  <map name="map">
                       //want ot get below onclick values one and park in to objective c .....
                  <area shape="circle" coords="1047,262,26" onclick="one" />
                  <area shape="circle" coords="1118,590,24" onclick="park" />
                  </a></map>
                  

                  对于 Obj-c

                   - (BOOL)webView:(UIWebView*)aWebView shouldStartLoadWithRequest:(NSURLRequest*)request  navigationType:(UIWebViewNavigationType)navigationType
                  {
                  NSString *absoluteUrl = [[request URL] absoluteString];
                  if ([absoluteUrl isEqualToString:@"didTap://button1"]) {
                    //        
                  UIAlertView *myAlert = [[[UIAlertView alloc] initWithTitle:@"Connectivity!" message:@" Hello" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil] autorelease];
                      [myAlert show];
                  
                  //the below line of code should get the string but its not working
                  
                   NSString* html = [myWeb stringByEvaluatingJavaScriptFromString:@"document.getElementById('circle').onclick"]; 
                  
                      return NO;
                  }
                  return YES; }
                  

                  可能的答案

                  //Html coding
                  <area  shape="circle" coords="1047,262,26" onclick="one" href="didTap://button1" value="one" />
                  <area  shape="circle" coords="1118,590,24" onclick="park" href="didTap://button2"  value="park"/>
                  
                  
                    //Obj C
                  
                  - (BOOL)webView:(UIWebView*)aWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
                  {
                  NSString *absoluteUrl = [[request URL] absoluteString];
                  if ([absoluteUrl isEqualToString:@"didTap://button1"]) {
                      UIAlertView *myAlert = [[[UIAlertView alloc] initWithTitle:@"Selected  Location!"  message:@"One" delegate:self cancelButtonTitle:@"GetDirection"  otherButtonTitles:@"Quit",nil] autorelease];
                      [myAlert show];
                  
                      return NO;
                   }
                   if ([absoluteUrl isEqualToString:@"didTap://button2"]) 
                   {
                       UIAlertView *myAlert = [[[UIAlertView alloc] initWithTitle:@"Selected  Location!"  message:@"Park" delegate:self cancelButtonTitle:@"GetDirection"  otherButtonTitles:@"Quit",nil] autorelease];
                       [myAlert show];
                       return NO;
                   }
                  return YES;
                  }
                  

                  推荐答案

                  我不确定您所说的从 HTML 获取"到底是什么意思.最可能的解决方案是使用 UIWebView javascript 方法:-(NSString*)stringByEvaluatingJavaScriptFromString:

                  I am not sure what exactly you mean by "fetch from HTML". The most likely solution will be to use UIWebView javascript method: -(NSString*)stringByEvaluatingJavaScriptFromString:

                  如果你想从id为'test'的标签中获取innerHTML:

                  If you want to get the innerHTML from the tag with id 'test':

                  NSString *innerHTML = [aWebview stringByEvaluatingJavaScriptFromString:@"document.getElementById('test').innerHTML"];
                  

                  这篇关于如何在 iphone 中使用 UIWebview 使图像地图可点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:UIWebView VS WKWebView 加载本地html 下一篇:如何在 viewWillDisappear 中安全地关闭正在加载的 UIWebView?

                  相关文章

                • <small id='LTkAB'></small><noframes id='LTkAB'>

                  • <bdo id='LTkAB'></bdo><ul id='LTkAB'></ul>

                      <legend id='LTkAB'><style id='LTkAB'><dir id='LTkAB'><q id='LTkAB'></q></dir></style></legend>

                      <i id='LTkAB'><tr id='LTkAB'><dt id='LTkAB'><q id='LTkAB'><span id='LTkAB'><b id='LTkAB'><form id='LTkAB'><ins id='LTkAB'></ins><ul id='LTkAB'></ul><sub id='LTkAB'></sub></form><legend id='LTkAB'></legend><bdo id='LTkAB'><pre id='LTkAB'><center id='LTkAB'></center></pre></bdo></b><th id='LTkAB'></th></span></q></dt></tr></i><div id='LTkAB'><tfoot id='LTkAB'></tfoot><dl id='LTkAB'><fieldset id='LTkAB'></fieldset></dl></div>

                      <tfoot id='LTkAB'></tfoot>