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

    1. <small id='LX79V'></small><noframes id='LX79V'>

    2. <tfoot id='LX79V'></tfoot>

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

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

        将方向更改为横向后,uiwebview 未调整大小

        时间:2023-10-22
          <tbody id='RQVYR'></tbody>
        <i id='RQVYR'><tr id='RQVYR'><dt id='RQVYR'><q id='RQVYR'><span id='RQVYR'><b id='RQVYR'><form id='RQVYR'><ins id='RQVYR'></ins><ul id='RQVYR'></ul><sub id='RQVYR'></sub></form><legend id='RQVYR'></legend><bdo id='RQVYR'><pre id='RQVYR'><center id='RQVYR'></center></pre></bdo></b><th id='RQVYR'></th></span></q></dt></tr></i><div id='RQVYR'><tfoot id='RQVYR'></tfoot><dl id='RQVYR'><fieldset id='RQVYR'></fieldset></dl></div>
        <legend id='RQVYR'><style id='RQVYR'><dir id='RQVYR'><q id='RQVYR'></q></dir></style></legend>

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

          <bdo id='RQVYR'></bdo><ul id='RQVYR'></ul>

                1. <tfoot id='RQVYR'></tfoot>
                  本文介绍了将方向更改为横向后,uiwebview 未调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在编写一个 iPhone 应用程序,其中我有一个 UIWebView 可以加载具有响应式设计的网站.

                  I'm coding an iPhone app in which I have a UIWebView that loads a website with a responsive design.

                  我遇到的问题是当我将设备旋转到横向时:UIWebView 旋转但它保持与纵向模式相同的宽度.

                  The problem I have is when I rotate the devices to landscape: the UIWebView rotates but it keeps the same width as the portrait mode.

                  我花了最后 5 个小时在网上搜索,我找到了一些我使用但没有成功的解决方案......

                  I spent the last 5 hours searching all over the net, I found some solutions that I used but without success...

                  在我正在使用的 html 页面中

                  in my html page i'm using

                  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
                  

                  我尝试使用

                  <meta name="viewport" content="width=device-width" />
                  

                  什么都没有改变,在我的代码中我正在实现以下函数来处理旋转,但它什么也没做

                  nothing changed, in my code I'm implementing the following function to handle the rotate, but it gives nothing

                  - (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation
                  {
                      [self.myWebView stringByEvaluatingJavaScriptFromString:
                      [NSString stringWithFormat:
                      @"document.querySelector('meta[name=viewport]').setAttribute('content', 'width=%d;', false); ",
                      (int)self.myWebView.frame.size.width]];
                  
                      NSLog(@"orientation width: %d", (int)self.myWebView.frame.size.width);
                  
                  }
                  

                  我还选中了缩放页面以适应"复选框,

                  I also checked the "Scale Page to Fit" checkbox,

                  (使用 xcode 5,使用 iphone4s 和 ios7)

                  (using xcode 5, with an iphone4s and ios7)

                  推荐答案

                  尝试在 UIWebView 上设置约束.当 View 旋转时,空间约束应该会自动调整.

                  Try setting constraints on the UIWebView. When the View rotated, the space constraints should automatically adjust.

                  在故事板中,查找右下角的菜单图标.选择自动布局图标(看起来像平手),然后选择添加缺失的约束"或重置为建议的约束".

                  In the storyboard, look for the menu icons in the lower right. Select the auto layout icon (looks like a tie fighter), and then select either 'Add Missing Constraints' or 'Reset to Suggested Constraints'.

                  这篇关于将方向更改为横向后,uiwebview 未调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:当 scalesPageToFit 为 ON 时 UIWebView 禁用缩放 下一篇:为什么在 UIWebView iPhone 中滚动时计时器停止?

                  相关文章

                2. <legend id='Ps12O'><style id='Ps12O'><dir id='Ps12O'><q id='Ps12O'></q></dir></style></legend>

                      <bdo id='Ps12O'></bdo><ul id='Ps12O'></ul>

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

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