A
A
Alexander2017-04-21 12:37:50
iOS
Alexander, 2017-04-21 12:37:50

Swift WebView and white screen in simulator, what's wrong?

import UIKit

class ViewController: UIViewController {
    
    @IBOutlet weak var webview: UIWebView! 
    
    func loadAddressUrl(){
        
        if let url = NSURL(string: "http://google.com/"){
            let request = NSURLRequest(URL: url)
        
            webview?.scalesPageToFit = true
            webview?.loadRequest(request)
        }
    }
    

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        loadAddressUrl()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
}

The simulator has a white screen, the site does not load...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pesenka1, 2017-04-21
@pesenka1

I assume that the problem is using an insecure http connection
Those. You need to either use https or set up exclusions in your .plist

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question