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

时间:2011-09-05 20:12:03

标签: uiwebview

为什么我的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一样有效。

然后我将其旋转到横向,上面的webViewContentHeight根本不会改变。而且,当然,UIButton一直保持在肖像的高度(呃)webViewContentHeight的位置。

???

1 个答案:

答案 0 :(得分:2)

在这里查看我的“Safari like”浏览器实现: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;