UIWebView changes contentSize on iOS 7 after coming back from background
ios, ios7, iphone, objective-c, uiwebview
Solution
"I am using a UIWebView in my UIViewController that is embedded in a UITabBarViewController that is embedded in a UINavigationController".
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)
Navigation view controller
Tab bar controller
Split view controller
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.
Problem
The Problem: 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. 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. Screenshot (redacted sensitive info): My Settings: 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. Relevant Code: ``` self.webView.scrollView.scrollEnabled = NO; self.webView.scrollView.bounces = NO; self.webView.scalesPageToFit = NO; ``` After monitoring contentSize & frame in `viewDidAppear` & `appHasGoneInForeground`: 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!