我有一个加载一些内容的基本网络视图,我已经将宽度和高度设置为主屏幕边界,它在iPhone 4s中运行良好,但对于5、5s等,webivew不适合每一页pdf的整个屏幕高度。请帮忙。我在stackoverflow上试过所有东西,但没有提到页面高度和设备高度。
let bounds = UIScreen.mainScreen().bounds
let h = bounds.size.height
let w = bounds.size.width
let webView = UIWebView(frame: CGRectMake(0,0,w,h))
webView.loadData(pdfData, MIMEType: "application/pdf", textEncodingName: "UTF-8", baseURL: req)
webView.scalesPageToFit = true
webView.frame=self.view.bounds;
webView.backgroundColor = UIColor.redColor()
self.view.addSubview(webView)
不要使用边界。获取屏幕的frame height
和frame width
。这基本上可以让web视图占据整个视图的框架。