我设法在我的UIWebView中加载了一个网站,但我无法将其集中在一起。 我也希望能够#34;导航"进入网站。我做错了什么?
这里是代码:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var WebView: UIWebView!
var URLPath = "http://google.fr"
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
WebView.scalesPageToFit = true
WebView.keyboardDisplayRequiresUserAction = true
loadAdressURL()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func loadAdressURL () {
let requestURL = NSURL(string:URLPath)
let request = NSURLRequest(URL: requestURL)
WebView.loadRequest(request)
}
}
这是IOS模拟器:
罗布。
答案 0 :(得分:3)
添加此
override func viewDidAppear(animated: Bool) {
WebView.frame = UIScreen.mainScreen().bounds
WebView.center = self.view.center
}