我有一个电子邮件应用程序,
它显示在内容UIWebView
内的UISplitViewController
。
在放大/缩小之前,一切工作正常,直到我旋转设备UIWebView
。当旋转装置中,我调整的帧UIWebView
中
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
问题是,当我放大/缩小UIWebView
然后旋转设备时。
内容没有调整为新框架的大小,这会导致内容中出现灰色/黑色边框,或者可以将内容水平滚动。
附加信息:UIWebView
是UIScrollView
可滚动的的子视图。当UIWebView
完全可见时scrollEnabled
,的会UIScrollView
被禁用,并且UIWebView
可以滚动。
上图显示了UIWebView
选择电子邮件时的横向视图。
两种情况下都是旋转前的状态。
[旋转前未缩放]上图显示,UIWebView
正在将内容正确调整为新帧的大小。
[转之前已缩放]上面的图片显示的UIWebView
景观缩放和旋转,然后向遗像- >内容是不会显示正确
的信息UIWebView.scrollView
在
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
:
<_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];
我设法通过旋转设备后更新视口宽度来解决此问题
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];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句