Ganesh Kumar
Ganesh Kumar

Reputation: 1651

IOS UIWebView is not loading the full website

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

Answers (2)

Anbu.Karthik
Anbu.Karthik

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

enter image description here

Upvotes: 1

keji
keji

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.

Site mentioned in code

Upvotes: 1

Related Questions