Vimeo视频在UIWebView上不合适,很快

时间:2016-06-19 10:27:08

标签: ios iphone swift uiwebview vimeo

我终于设法在UIWebView中显示我的vimeo视频。 UIWebView的大小是w = 280,h = 204。

这是视频在UIWebView中的拟合方式:

enter image description here

然后我可以将视频拖动到我希望它在加载视图时首先出现的位置:

enter image description here

这是我用来显示视频的代码:

let embedHTML="<html><head><style type=\"text/css\">body {background-color: transparent;color: white;}</style></head><body style=\"margin:0\"><iframe src=\"//player.vimeo.com/video/171151492?autoplay=1&amp;loop=1\" width=\"280\" height=\"204\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";

webView.delegate = self
let url: NSURL = NSURL(string: "https://player.vimeo.com/video/171151492")!
webView.loadHTMLString(embedHTML as String, baseURL:url )

1 个答案:

答案 0 :(得分:1)

您的视图控制器会尝试将UIWebView的滚动视图插入内容调整到导航栏。

您可以将视图控制器的automaticallyAdjustsScrollViewInsets属性设置为false,如下所示,以防止出现这种情况:

self.automaticallyAdjustsScrollViewInsets = false

或者从Interface Builder中取消选中Layout部分下视图控制器的“Adjust Scroll View Inset”选项。