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

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

  • <legend id='AoyzK'><style id='AoyzK'><dir id='AoyzK'><q id='AoyzK'></q></dir></style></legend>
      • <bdo id='AoyzK'></bdo><ul id='AoyzK'></ul>

        获取 UIWebView 内容的高度

        时间:2023-10-22
      1. <legend id='PmhMG'><style id='PmhMG'><dir id='PmhMG'><q id='PmhMG'></q></dir></style></legend>
          <tbody id='PmhMG'></tbody>
            • <bdo id='PmhMG'></bdo><ul id='PmhMG'></ul>

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

              <tfoot id='PmhMG'></tfoot>
              <i id='PmhMG'><tr id='PmhMG'><dt id='PmhMG'><q id='PmhMG'><span id='PmhMG'><b id='PmhMG'><form id='PmhMG'><ins id='PmhMG'></ins><ul id='PmhMG'></ul><sub id='PmhMG'></sub></form><legend id='PmhMG'></legend><bdo id='PmhMG'><pre id='PmhMG'><center id='PmhMG'></center></pre></bdo></b><th id='PmhMG'></th></span></q></dt></tr></i><div id='PmhMG'><tfoot id='PmhMG'></tfoot><dl id='PmhMG'><fieldset id='PmhMG'></fieldset></dl></div>
                • 本文介绍了获取 UIWebView 内容的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个使用 loadHtmlString 函数加载数据的 uiwebview.问题是我正在从 sqlite 数据库加载数据,每次我加载不同长度的不同字符串时,Web 视图自然会获得不同的高度.
                  现在我每次都需要知道 uiwebview 的确切高度,以便在 webView 正下方加载 imageView.我试过了

                  I have a uiwebview that loads data using the loadHtmlString function.The thing is i am loading the data from an sqlite database, each time i load a different string with different length and naturally the web view obtains different height.
                  Now i need to know each time the exact height of the uiwebview in order to load an imageView right under the webView. I have tried

                  - (void)webViewDidFinishLoad:(UIWebView *)aWebView {
                      CGRect frame = aWebView.frame;
                      frame.size.height = 1;
                      aWebView.frame = frame;
                  
                      CGSize fittingSize = [aWebView sizeThatFits:CGSizeZero];
                      frame.size = fittingSize;
                      aWebView.frame = frame;
                  
                      NSLog(@"Size: %f, %f", fittingSize.width, fittingSize.height);
                  }
                  

                  但我总是得到相同的结果.我需要知道如何在每次加载时动态获取 Web 视图的高度.谢谢

                  but i always get the same result. I need to know how can i get dynamically the height of web view each time it is loaded. Thx

                  推荐答案

                  这不是处理这种情况的正确方法;而不是在图像视图中加载图像并且必须始终牢记高度和宽度以及所有这些东西......最简单和最可靠的解决方案就是将图像加载到 html 字符串中,就是这样!只要确保 baseURL 如此,无论您采取什么方向,一切都会好起来的:

                  This wasn't the right approach to handle this situation; instead of loading the image in an image view and having to keep always in mind the height and width and all that stuff...The easiest and most reliable solution was just to load the image inside the html string and that's it ! Just be sure of the baseURL as so and everything will be ok no matter what orientation you take :

                   NSString* extension = @"gif";
                      NSString* strRR = [NSString stringWithFormat:@"%@.%@", authorNAme2,extension];
                      NSString *path = [[NSBundle mainBundle] bundlePath];
                      //NSLog(@"This is the path %@", path);
                      NSURL *baseURL = [NSURL fileURLWithPath:path];
                      //  NSLog(@"this is the base URL %@",baseURL);
                  
                      NSString *cachePath = [NSString stringWithFormat:@"%@/%@", path,strRR];
                  
                              NSString * htmlString = [NSString stringWithFormat:@"
                                                       <html>
                                                       <table width='100%%'><tr><td>
                                                       <body>
                                                       <p style = 'font-size:30px;'> %@ <p>
                                                       </td></tr><tr><td><br></td></tr><tr><td align ='center'><br><img src='%@' width='60%%' ></td></tr></body>
                                                       </table>
                                                       </html>",authorNAme , cachePath];
                  
                  
                  
                              //          NSString *selection = [WebV2 stringByEvaluatingJavaScriptFromString:@"window.getSelection().toString()"];
                              //          NSLog(@"*/*/*/*/**/*/*/*/*/*/*//*/ This is your selection mate %@" , selection);
                  
                  
                  
                  
                              WebV.opaque = NO;
                              WebV.backgroundColor = [UIColor clearColor];  
                              [self.WebV setScalesPageToFit:YES];
                              [self.WebV loadHTMLString:htmlString baseURL:baseURL];
                  

                  这篇关于获取 UIWebView 内容的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在自定义控件中添加放大镜? 下一篇:比较两个 NSURL 或一个 NSURL 和一个 NSString 的可靠方法?

                  相关文章

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

                      <bdo id='z1iFN'></bdo><ul id='z1iFN'></ul>
                  1. <tfoot id='z1iFN'></tfoot>
                    <legend id='z1iFN'><style id='z1iFN'><dir id='z1iFN'><q id='z1iFN'></q></dir></style></legend>
                  2. <small id='z1iFN'></small><noframes id='z1iFN'>