uz7
uz7

Reputation: 159

WebView shows blank white screen part from apple.com

I have added a web view to my app however i keep getting a blank white screen when running on simulator or even device. When i enter apple.com as the website it works perfect but for any other website it just shows a blank white screen. import UIKit

class ViewController: UIViewController {

 @IBOutlet var WebView: UIWebView!

override func viewDidLoad() {
super.viewDidLoad()


var URL = NSURL(string: "http://www.apple.com")

WebView.loadRequest(NSURLRequest(URL: URL!))

}

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


}

Upvotes: 1

Views: 3787

Answers (2)

Rashwan L
Rashwan L

Reputation: 38833

Have you added autolayout to your webView? As the image below shows? enter image description here

Just select your webView and click on Add New Constraints and set your constraints.

If this is not your issue, check the output window if it blocks requests that are not HTTPS, then you can add this code to your info.plist code.

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

Update
You´re getting the white screen because you´re missing the http:// in your URL.

Upvotes: 2

Wasif Saood
Wasif Saood

Reputation: 2008

enter image description hereIn Plist of the app give App Transport Security Settings,Give dictionary and then under it Allow Arbitrary Loads And set bool to YES, as in iOS 9 you have to give https request, Or simply add https with url, it will work

Upvotes: 0

Related Questions