I have a fairly simple scene, with a single UIWebView that loads an html document from the bundle. The webView fills the screen below the top layout guide, and uses the recommended constraints. It has two odd behaviors:
It starts with the content scrolled down a bit. You can see this in the first image below. The pink is the color of the UIWebView, and the html itself is white.
There is something goofy about the webView's UIScrollView itself, because (again: see pic) the content is scrolled all the way to the bottom, but the scroller isn't at the top of the webView; it's at the top of the content.
The content does easily scroll into that pink region, and when the content is scrolled all the way up, the scroll bar is at the bottom of the UIWebView. See second image.
I realize that I can programmatically set the contentOffset, but it only works in the webViewDidFinishLoad function and then it causes a visible jump, because the webview draws itself first and then scrolls, so that's no good.
Here is the html (truncated for space):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="help.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h2>Frequently-asked questions</h2>
</body>
</html>
And the CSS:
@charset "UTF-8";
body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-size: 16px;
}
And here is the ViewController:
class HelpViewController: UIViewController, UIWebViewDelegate {
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let navController = self.navigationController
navController?.navigationBarHidden = false
}
override func viewWillAppear(animated: Bool) {
loadURL();
}
func loadURL() {
let htmlName = "support";
let url = NSBundle.mainBundle().URLForResource(htmlName, withExtension: "html")
self.webView.delegate = self;
if let goodURL = url {
let request = NSURLRequest(URL: goodURL)
self.webView.loadRequest(request)
}
}
}
It seems like the problem must be related to something in IB, but I don't see what. Any bright ideas?
Thanks in advance!
-Dave

