Added whitespace in UIWebview - removing UIWebView whitespace in iOS7 & iOS8

DevC picture DevC · Sep 22, 2013 · Viewed 17.4k times · Source

Im loading local html files, since iOS7 there is added white space on top in the UIWebView.(I cant post an image as i do not have enough points.) image can be seen here- snap shot from iPhone simulator, uiwebview surrounded by black frame, the html content is grey, but there is white added above it

I have tried to adjust the zoom using

[webView stringByEvaluatingJavaScriptFromString:@"document. body.style.zoom = 5.0;"];
webView.scalesPageToFit = NO;

I also set tried to remove white spacing:

 NSString *padding = @"document.body.style.margin='0';document.body.style.padding = '0'";
[webView stringByEvaluatingJavaScriptFromString:padding];

still no luck. In the desktop chrome browser there is no whitespace. The html files are Google Swiffy files - containing html and JSON.

edit: updated Image

Answer

Yiding picture Yiding · Oct 2, 2013

Try self.automaticallyAdjustsScrollViewInsets = NO; in ViewDidLoad.

ios 7 add 64px automatically for scroll view. (status bar and nav bar)