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
设置为clear
color
.
- Set
UIWebView's
opaque
toNO
- Set
UIWebView's
backgroundcolor
toclear
color
.
注意:以上提供的两件事都是必需的.
使用上述方案时的其他解决方案
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 底部出现黑线.如何去除?
基础教程推荐
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01