Black bar appearing in UIWebview when device orientation changes

大憨熊 提交于 2019-12-20 09:21:56

问题


I have a UIWebView that I am loading onto another view, everthing looks fine in portrait or landscape when rotating, however when I am in portrait and I zoom in slightly with pinch or double tap when I rotate from portrait to landscape the view dosnt fill completely with the uiwebview, there are about 10pxls on the right that turn black as outlined in this screen shot.

if you look carefully you can see the outline of the scroll indicator in the black, which segests this is part of the uiwebview?? if so then why dose it turn black in this area.

Also heres another screen shot of the webview scrolled up abit so you can see its part of the uiwebview...

This is how I am adding the view onto the detail view.

- (void)viewdidload
//..

//Load in FirstView
    firstView = [[FirstMainViewController alloc] init];
    firstView.view.frame = CGRectMake(0.0, 0.0, firstView.view.bounds.size.width, firstView.view.bounds.size.height);

    firstView.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    firstView.view.backgroundColor = [UIColor whiteColor];

    [self.view insertSubview:firstView.view belowSubview:actionTabBar]; 

//..

回答1:


Try to set the background of the webView transparent (clearColor) and set it's opaque property to FALSE. Then make the background white in your html or simply have the view beneath the webView white.




回答2:


I had the same problem, and simply setting opaque to NO fixed it. Didn't even have to change the background color, it works fine with the background color set to white.




回答3:


I put in the line...

webView.scrollView.backgroundColor = UIColor.whiteColor()

webView is my @IBOutlet weak var webView: UIWebView!




回答4:


Turn off WebKitDiskImageCacheEnabled and the black border goes away :
In applicationDidFinishLaunchingWithOptions add the following lines :

[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDiskImageCacheEnabled"];
[[NSUserDefaults standardUserDefaults] synchronize];


来源:https://stackoverflow.com/questions/11388534/black-bar-appearing-in-uiwebview-when-device-orientation-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!