Search code examples
iosswiftwebviewuiwebview

Can't load http authorisation website url in webview on IOS9 with swift 2


I'm now to IOS development and i encounter a problem that i can't load a http authorisation site in webview, it just show blank page and nothing comes out, here is my code to load the website:

@IBAction func testhttp(sender: AnyObject) {

    let url = NSURL(string: "http://www.obee.com.au/demo/admin/index.php");
    let request = NSURLRequest(URL: url!);
    //see2 is the webview....
    see2.loadRequest(request);
}

Can anyone help me fix this problem ?

Cheers


Solution

  • It seems like it needs an authentication to load the page. You might fix it with providing credential info in the header of NSURLRequest.

    How to make an HTTP request + basic auth in Swift