Reputation: 1651
i am learning iOS. i am trying to load a website in the UIWebView. The webpage is loading but the web view is not loading the full website. Instead the web view loads partial page of the website. Here is the code what have i done wrong??
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.
}
}
Upvotes: 2
Views: 1640
Reputation: 82766
choice -1
webView.scalesPageToFit = true
if it is not work try choice no -2
choice -2
webView.frame = UIScreen.mainScreen().bounds
webView.center = self.view.center
webView.scalesPageToFit = true
choice -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)
additional reference1, reference2
here I attached the sample project
the project output
Upvotes: 1
Reputation: 5990
Nothing is wrong at all. There is no problem whatsoever with the code. I'm not sure why you split the screenshot but the website has a mobile version and that's what your seeing. They purposely made it look like that. They scale it to the devices width and remove elements if needed.
Upvotes: 1