问题:
我的 UINavigationBar
和 UITabBar
之间有一个 UIWebView
.在 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
,该 UIWebView
嵌入在 UINavigationController
UITabBarViewController 中>.我正在使用情节提要并启用调整滚动视图插图"、从 NIB 调整视图大小"和在 Tob 栏下扩展边缘".在 UIWebView
我没有选中缩放页面以适应".我没有在 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 变为 320x455contentSize 从 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,该 UIWebView 嵌入在 UINavigationController 中的 UITabBarViewController 中".
"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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!