我正在学习 iOS。我正在尝试在 UIWebView 中加载网站。网页正在加载,但 Web View 未加载整个网站。相反, WebView 会加载网站的部分页面。这是代码
我做错了什么??
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
webView.frame = self.view.frame
let url = "http://www.tradiestart.com.au"
let requestUrl = NSURL(string: url)
let request = NSURLRequest(URL: requestUrl!)
webView.loadRequest(request)
webView.scrollView.scrollEnabled = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Best Answer-推荐答案 strong>
选择-1
webView.scalesPageToFit = true
if it is not work try choice no -2
选择-2
webView.frame = UIScreen.mainScreen().bounds
webView.center = self.view.center
webView.scalesPageToFit = true
选择-3
webView.frame =CGRectMake(0,0, self.view.frame.size.width , self.view.frame.size.height)
or
webView.frame =CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height)
附加 reference1 , reference2
这里我附上了 sample project
项目输出
关于IOS UIWebView 没有加载完整的网站,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/32390336/
|