2011-09-05 109 views
2

爲什麼我的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 .. 。一切都像肖像一樣。

然後我將它旋轉到橫向,上面的webViewContentHeight根本不會改變。而且,當然,UIButton會保留在Portrait(高)(呃)webViewContentHeight的位置。

???

回答

2

在我的「野生動物園,如」瀏覽器實現看看這裏:https://github.com/sylverb/CIALBrowser

基本上,確保所有的自動尺寸口罩都OK!對於我的工具欄和一個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; 
+0

我自動尺寸口罩的樣子: –

+0

哎呦 - 打回得太快 - 反正,機頂支柱,並設置兩個彈簧 - 問題解決了,感謝束。事實上,我唯一剩下的問題就是設計那些被詛咒的@ 2X等圖形。我以非常簡單的方式使用GraphicConverter,並且非常適合Web頁面設計。但是,所有這些30px,57px的東西 - 至少我會進入我的未知領域。 –

相關問題