override func viewDidLoad() {
super.viewDidLoad()
secondVideoPlayer.allowsInlineMediaPlayback = true
secondVideoPlayer.loadHTMLString("<iframe width=\"\(newVideoPlayer.frame.width)\" height=\"\(newVideoPlayer.frame.height)\" src=\"\(urlString)?&playsinline=1\" frameborder=\"0\" allowfullscreen></iframe>",baseURL: nil)
}
Youtube 视频位置开始不正确,要正确查看它我总是必须拖动它我该如何解决?如何手动设置他的起始位置?
最佳答案
将 iframe
包裹在 body
中,并将 margin
和 padding
设置为零,这样内容就开始了从左上角开始。
secondVideoPlayer.loadHTMLString("<body style=\"margin: 0; padding: 0;\"><iframe width=\"\(newVideoPlayer.frame.width)\" height=\"\(newVideoPlayer.frame.height)\" src=\"\(urlString)?&playsinline=1\" frameborder=\"0\" allowfullscreen></iframe></body>",baseURL: nil)
secondVideoPlayer.scrollView.bounces = false
关于swift - WebView嵌入youtube视频位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40209696/