我有一個電子郵件應用程序,
它顯示內的UISplitViewController
內容。
一切正常,直到我旋轉設備,當已經放大/在UIWebView
。 當旋轉裝置中,我調整UIWebView
的幀中
UIWebView內容在旋轉後未調整爲新幀
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
的問題是,當我在UIWebView
放大/縮小,然後旋轉該裝置。
內容未被調整爲新框架的大小,這會導致內容中出現灰色/黑色邊框,或者內容可能會水平滾動。
Addional information: UIWebView
是可以滾動的UIScrollView
的子視圖。 當UIWebView
完全可見時,UIScrollView
的scrollEnabled
被禁用,並且可以滾動UIWebView
。
上圖顯示選擇電子郵件時的橫向UIWebView
。
這是兩種情況下旋轉前的狀態。
上面的照片示出了UIWebView
被正確調整所述內容到它的新的幀[不旋轉之前放大。
橫向縮放和旋轉,然後以肖像 後上面圖爲UIWebView
[旋轉之前已縮放] - 在- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
>內容不正確顯示
的UIWebView.scrollView
的信息:
<_UIWebViewScrollView: 0xb1322a0; frame = (0 0; 768 960); clipsToBounds = YES; autoresize = H; gestureRecognizers = <NSArray: 0xb1321d0>; layer = <CALayer: 0xb132270>; contentOffset: {0, 0}>
框架是正確的!
編輯:解決方案!
我設法通過旋轉裝置之後更新所述視口寬度來解決它
CGFloat fll_width = self.view.frame.size.width; NSString* adsl_javascript_string = [NSString stringWithFormat:@"var setViewPortScript = document.createElement('meta');\ setViewPortScript.setAttribute('name', 'viewport');\ setViewPortScript.setAttribute('content', 'width = %f');\ document.getElementsByTagName('head')[0].appendChild(setViewPortScript);", fll_width]; [adsc_webview stringByEvaluatingJavaScriptFromString:adsl_javascript_string];
你知道,一個'UIWebView'是UIScrollView'的'所以我只是想知道的邏輯是什麼,具有額外'子類UIScrollView'您所描述的所有內容都可以通過「UIWebView」來實現, – Popeye