我想向您询问我在项目中遇到的问题。问题是我正在尝试显示 UIWebView
控件,我正在将视频流加载到 Web View 中,这是代码:
if(self.cameraUrl != nil) {
let url = NSURL (string: self.cameraUrl!)
let requestObj = NSURLRequest(URL: url!)
self.view_webvideo.loadRequest(requestObj)
self.view_webvideo.contentMode = UIViewContentMode.Center;
let zoom = self.view_webvideo.bounds.size.width / self.view_webvideo.scrollView.contentSize.width
self.view_webvideo.scrollView.setZoomScale(zoom, animated: true)
}
正如您在代码中看到的那样,我对此进行了研究并尝试了很多方法,但我无法缩放内容,视频有 width=360
和 height=640
,我无法更改视频大小,因为它是第三方服务。
我还使用以下属性:Scales Page To Fit = true
我希望视频比例固定到 webview 组件中并且不显示任何滚动
我希望有人能帮助我。
提前谢谢您
最佳答案
尝试用此替换最后三行(类似于manman所说的)
self.view_webvideo.stringByEvaluatingJavaScriptFromString("document.getElementsByTagName('video')[0].style.width='100%'")
关于ios - 缩放 UIWebView 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33248740/