Search code examples
iosiphoneuiwebview

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.
}
}

Solution

  • 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