【问题标题】:why was content height of UIWebView not change with rotation为什么 UIWebView 的内容高度不随旋转而变化
【发布时间】:2011-11-10 20:36:02
【问题描述】:

为什么我的 UIWebView 的内容高度不随旋转而变化?

从纵向到横向,内容宽度应该扩大,内容高度应该缩小。它在视觉上是应有的,但不是根据我的 NSLog。

关于我的 UIView 的重要添加信息。

1) 我的 UIWebView 不是整个 UIView,而是我的整个 UIView 的子视图。

2) 第一次浏览我的代码,我通过以下方式将 UIWebView 的 frame.size.height 更改为 UIWebView 的 contentHeight:

UIScrollView *scrollViewInsideWebView = [[webView_ subviews] lastObject];
webViewContentHeight = scrollViewInsideWebView.contentSize.height;

好的,然后我们将我们的 UIButton 推到它下面......一切都可以正常使用 Portrait。

然后我将它旋转到 Landscape 并且上面的 webViewContentHeight 根本没有改变。而且,当然,UIButton 会在具有较高 webViewContentHeight 的 Portrait 中保持向下推。

???

【问题讨论】:

    标签: uiwebview


    【解决方案1】:

    在这里查看我的“类似 Safari”的浏览器实现:https://github.com/sylverb/CIALBrowser

    基本上,确保所有自动调整大小的蒙版都正常!对于我的带有工具栏和 UIWebView 的示例,我有

    self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    
    toolBar.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; // for a toolbar at the top of the view
    toolBar.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; // for a toolbar at the bottom of the view
    webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    

    【讨论】:

    • 我的自动调整蒙版看起来像:
    • 哎呀 - 回车太快了 - 无论如何,设置顶部支柱并设置两个弹簧 - 问题解决了,谢谢大家。事实上,我剩下的唯一问题就是设计那些被诅咒的@2X等图形。我以一种非常简单的方式使用 GraphicConverter,它非常适合网页设计,非常好。但是所有这些 30 像素、57 像素的东西 - 至少我要进入未知领域。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多