Ethan Humphries
Ethan Humphries

Reputation: 1836

UIWebView giving only a white screen - Xcode 7

Since the recent update to Xcode 7, I have found that my webView will no longer load, it will only show a white screen.

I have searched for a solution, to no avail.

I have coded the webView connection as follows:

class ViewController: UIViewController {

@IBOutlet weak var webviewInstance: UIWebView!

override func viewDidLoad() {
    super.viewDidLoad()

    // Connect UIWebView to the ordering page

    let url = NSURL (string: "http://www.google.com");
    let requestObj = NSURLRequest(URL: url!);
    webviewInstance.loadRequest(requestObj);
}

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


}

I would greatly appreciate any help with this.

Upvotes: 1

Views: 1539

Answers (2)

Lorenzo
Lorenzo

Reputation: 3387

You have to check the app plist file and add the AppTransportSecurity. Open your plist file and add this. Search for AppTransportSecurity

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>

If you don't add the ATS in your PLIST your link are ignored/blocked. I hope this can help you

Upvotes: 1

Leonardo
Leonardo

Reputation: 1750

A while back I remember reading a question here on SO saying that not implementing

- webView:shouldStartLoadWithRequest:navigationType: 

from UIWebViewDelegate was causing problems.

If that don't solve the issue, you can use the delegate methods to debug your problem

Upvotes: 1

Related Questions