从后台返回后,UIWebView在iOS 7上更改contentSize [英] UIWebView changes contentSize on iOS 7 after coming back from background

查看:269
本文介绍了从后台返回后,UIWebView在iOS 7上更改contentSize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

我的<$ c之间有一个 UIWebView $ c> UINavigationBar 和 UITabBar 。在iOS 7上,当应用程序进入后台并再次返回时,好像 UIWebView的 contentSize 属性更改,以便在其上方有一个白色块。

I have a UIWebView between my UINavigationBar and UITabBar. On iOS 7, when the app enters background and comes back again, it seems as if the contentSize property of the UIWebView changes so that there is a white block above it.

监控 UIWebView contentSize 后,应用程序进入前台(我通过观察 UIApplicationDidBecomeActiveNotification 来检查它),它从它的高度减去49。

After monitoring the contentSize of the UIWebView, when the application enters foreground (I check it by observing the UIApplicationDidBecomeActiveNotification), it has 49 substracted from it's height.

屏幕截图(编辑敏感信息):

我的设置:

我在我的 UIViewController 中使用 UIWebView ,它嵌入在 UITabBarViewController中嵌入在 UINavigationController 中。我正在使用故事板并具有调整滚动视图插入,从NIB调整视图大小和在条形图下扩展边缘。在 UIWebView 上,我取消选中Scales Page To Fit。我没有在 viewDidAppear viewWillAppear 方法中做任何事情。我在iOS 6上测试过它,问题不会发生在那里。另外,我没有使用自动布局。

I am using a UIWebView in my UIViewController that is embedded in a UITabBarViewController that is embedded in a UINavigationController. I am using Storyboards and having "Adjust Scroll View Insets", "Resize View From NIB" and "Extend Edges Under Tob Bars" on. On the UIWebView I have unchecked "Scales Page To Fit". I am not doing anything in the viewDidAppear or viewWillAppear methods. I tested it on iOS 6, and the problem doesn't occur there. Also, I am not using auto-layout.

相关代码:

self.webView.scrollView.scrollEnabled = NO;
self.webView.scrollView.bounces = NO;
self.webView.scalesPageToFit = NO;

监控contentSize& 中的框架viewDidAppear & appHasGoneInForeground

After monitoring contentSize & frame in viewDidAppear & appHasGoneInForeground:

帧从320x455变为320x455
contentSize从320x504变为320x455

Frame goes from 320x455 to 320x455 contentSize goes from 320x504 to 320x455

有没有人知道我在这里缺少什么和/或为什么会这样?感谢您的时间!

Does anyone have an idea what I am missing here and/or why this happens? Thanks for your time!

推荐答案

我在UIViewController中使用了一个UIWebView,它嵌入在嵌入在UITabBarViewController中的UITabBarViewController中UINavigationController。

"I am using a UIWebView in my UIViewController that is embedded in a UITabBarViewController that is embedded in a UINavigationController".

Apple不支持此功能。 链接

This is not supported by Apple. link


...遏制的顺序很重要;只有某些安排
有效。从子项到父项的遏制顺序如下:

...the order of containment is important; only certain arrangements are valid. The order of containment, from child to parent, is as follows:

内容视图控制器和具有
灵活范围的容器视图控制器(例如页面视图控制器)

Content view controllers, and container view controllers that have flexible bounds (such as the page view controller)

导航视图控制器

标签栏控制器

拆分视图控制器

我会首先尝试更简单有效的容器安排,看看它是否能解决问题。请注意,即使您解决了这个特定问题,如果继续使用您的层次结构,您仍可能遇到意外且可能不一致的UI问题。

I would try a simpler and valid container arrangement first to and see if it resolves the issue. Note that even if you solve this specific issue, if you keep using your hierarchy you may still run into unexpected and possibly inconsistent UI issues.

这篇关于从后台返回后,UIWebView在iOS 7上更改contentSize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆