Black line appearing at bottom of UIWebView. How to remove?(UIWebView 底部出现黑线.如何去除?)
问题描述
我在嵌入在表格单元格中的 web 视图中呈现一些 html.出于某种原因,webview 底部有一条黑线.我尝试将 webview 及其滚动视图的背景颜色设置为白色,但这并没有改变任何东西.有没有人见过这个?
I am rendering some html in a webview that is embedded in a table cell. For some reason there is a black line at the bottom of the webview. I tried setting the background color of the webview and its scrollview to white but this did not change anything. Has anyone seen this before?
这是正在呈现的 HTML:
Here is the HTML that is being rendered:
<html>
<head>
    <style type="text/css">
a {text-decoration:none;background-color:white;}
    </style>
    <title></title>
</head>
<body style="margin:0;padding:0;background-color:white;">
    <a href="http://body/" style=
    "font-family:HelveticaNeue-Light;font-size:20.000000;color:black;-webkit-tap-highlight-color:rgba(0,0,0,0);">
    Portland Blazers vs Golden State Warriors | FULL Highlights | January 26 ,
    2014 | NBA 2013-14 Season</a><span style=
    "font-family:HelveticaNeue;font-size:12.000000;color:rgb(102,102,102);white-space:nowrap;"><a href="https://www.youtube.com/watch?v=2TfldZ4w57E&feature=youtube_gdata_player"
    style=
    "font-family:HelveticaNeue;font-size:12;color:rgb(102,102,102);-webkit-tap-highlight-color:rgba(0,0,0,0);"><img height="12"
    src="file:link@2x.png" width="20">www.youtube.com</a></span>
</body>
</html>
这是在 iOS7 上.
This is on iOS7.
更新:我仍然不确定是什么导致了黑线出现,但我设法通过更改我设置布局约束的方式来摆脱它.在我为视图周围的间距设置约束并让布局系统确定视图的大小之前.当 webview 完成加载其内容时,我将其更改为显式设置 webview 的高度约束.这似乎已经解决了这个问题,但我仍然不明白黑线是从哪里来的.
UPDATE: I'm still not sure what is causing the black line to appear but I managed to get rid of it by changing how I setup my layout constraints. Before I was setting constraints for the spacing around the views and letting the layout system figure out the size that the view should be. I changed it to explicitly set a height constraint of the webview when the webview finishes loading its content. This seems to have fixed the issue but I still do not understand where the black line was coming from.
推荐答案
我有同样的问题,解决方案如下:
- 设置
UIWebView的opaque为NO - 将
UIWebView的backgroundcolor设置为clearcolor. 
- Set 
UIWebView'sopaquetoNO - Set 
UIWebView'sbackgroundcolortoclearcolor. 
注意:以上提供的两件事都是必需的.
使用上述方案时的其他解决方案
webView.scrollView.backgroundColor = UIColor.whiteColor()
或
HTML 头部标签中的元数据
The meta to go in the head tag of HTML
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
                        这篇关于UIWebView 底部出现黑线.如何去除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIWebView 底部出现黑线.如何去除?
				
        
 
            
        基础教程推荐
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
 - Android Volley - 如何动画图像加载? 2022-01-01
 - Play 商店的设备兼容性问题 2022-01-01
 - 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
 - SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
 - 如何比较两个 NSDate:哪个是最近的? 2022-01-01
 - UIImage 在开始时不适合 UIScrollView 2022-01-01
 - navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
 - iOS - UINavigationController 添加多个正确的项目? 2022-01-01
 - 如何将图像从一项活动发送到另一项活动? 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
				
				
				
				