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

Sakir Sherasiya
  • 1,562
  • 1
  • 17
  • 31
Aaron
  • 43
  • 8

3 Answers3

2

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

DragonCherry
  • 742
  • 7
  • 10
1

Add Following Line Code in info.plist:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

Screen shot:

NSAlowArbitaryLoads

Sakir Sherasiya
  • 1,562
  • 1
  • 17
  • 31
0

Go to your plist, Right click on Information property list click add new row then add new row as app transport security system and inside this row add allow arbitrary load as yes

enter image description here

Naqeeb
  • 1,121
  • 8
  • 25