zeeple
zeeple

Reputation: 5617

UIWebView Produces Blank White Screen

I am having trouble resolving an odd issue with my webView. I am attempting to load a web page (any web page) in a webView which is the sole object within a UIViewController. When I create an instance of the view controller and push it onto the stack, the screen is blank and white. For now I am attempting to load www.apple.com. Here is the relevant code:

UIViewController:

import UIKit

class GoodReadsVC: UIViewController {

    @IBOutlet weak var webView: UIWebView!

    override func viewDidLoad() {
        super.viewDidLoad()

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

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

}

For what it is worth, I know that the webView is indeed connected to the xib, due to the little dot being filled in the left margin.

Pushing the controller onto the nav stack:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

        let bookWebView = GoodReadsVC(nibName: "GoodReadsVC", bundle: NSBundle.mainBundle())
        self.navigationController!.pushViewController(bookWebView, animated: true)


        tableView.reloadData()
}

What am I doing wrong?

Upvotes: 3

Views: 11474

Answers (1)

zeeple
zeeple

Reputation: 5617

This was a case of the loading being blocked by this error:

Transport security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

The solution to this problem may be found here:

Transport security has blocked a cleartext HTTP

Upvotes: 4

Related Questions