Ios UIWebView内容在更改方向时部分丢失?
我正在为iPad构建一个阅读文章的应用程序,并使用拆分视图控制器。 UIViewController包含uiscrollview作为子视图,uiscrollview包含uiwebview作为子视图和三个标签。 我已禁用uiwebview的滚动,并根据uiwebview的内容大小和uiscrollview中的标签设置滚动高度。 当我将方向肖像更改为横向时,我面临一个问题,uiweview中的内容部分丢失 这是我的密码:Ios UIWebView内容在更改方向时部分丢失?,ios,objective-c,uiwebview,uiscrollview,screen-orientation,Ios,Objective C,Uiwebview,Uiscrollview,Screen Orientation,我正在为iPad构建一个阅读文章的应用程序,并使用拆分视图控制器。 UIViewController包含uiscrollview作为子视图,uiscrollview包含uiwebview作为子视图和三个标签。 我已禁用uiwebview的滚动,并根据uiwebview的内容大小和uiscrollview中的标签设置滚动高度。 当我将方向肖像更改为横向时,我面临一个问题,uiweview中的内容部分丢失 这是我的密码: - (void)webViewDidFinishLoad:(UIWebV
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
CGSize mWebViewTextSize = [webView sizeThatFits:CGSizeMake(1.0f, 1.0f)]; // Pass about any size
CGRect mWebViewFrame = webView.frame;
mWebViewFrame.size.height = mWebViewTextSize.height;
webView.frame = mWebViewFrame;
webView.scrollView.scrollEnabled = NO;
webView.scrollView.bounces = NO;
scroller.translatesAutoresizingMaskIntoConstraints = NO;
webView.translatesAutoresizingMaskIntoConstraints = NO;
scroller.contentSize = CGSizeMake(scroller.frame.size.width, webView.frame.size.height+260);
for (id subview in webView.subviews)
{
if ([[subview class] isSubclassOfClass: [UIScrollView class]])
{
[subview setBounces:NO];
[subview setScrollEnabled:NO];
}
}
}
您需要根据iPad的方向调整WebView的框架,尝试根据UIInterfaceOrientation上的视图框架调整WebView的框架,然后重新加载WebView