Xcode WKWebView (IOS) Wont Load Webpage, White Screen












0















I have searched for a few hours now and tried many solutions and none seem to work.



I have disabled my AVG web shield, added this to my plist under App transport



    <key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>


Code below



    let link = URL(string: "https://stackoverflow.com")!
let req = URLRequest(url: link)
webView.navigationDelegate = self
webView.uiDelegate = self
self.view.addSubview(webView)
self.view.bringSubview(toFront: webView)
self.webView!.load(req)


I am extremely confused why any web page does not load



I have tried http and https



I have tired multiple websites, no luck



it just stays on a blank white screen










share|improve this question



























    0















    I have searched for a few hours now and tried many solutions and none seem to work.



    I have disabled my AVG web shield, added this to my plist under App transport



        <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionAllowsInsecureHTTPLoads</key>
    <true/>
    <key>NSIncludesSubdomains</key>
    <true/>
    <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>


    Code below



        let link = URL(string: "https://stackoverflow.com")!
    let req = URLRequest(url: link)
    webView.navigationDelegate = self
    webView.uiDelegate = self
    self.view.addSubview(webView)
    self.view.bringSubview(toFront: webView)
    self.webView!.load(req)


    I am extremely confused why any web page does not load



    I have tried http and https



    I have tired multiple websites, no luck



    it just stays on a blank white screen










    share|improve this question

























      0












      0








      0








      I have searched for a few hours now and tried many solutions and none seem to work.



      I have disabled my AVG web shield, added this to my plist under App transport



          <key>NSAllowsArbitraryLoads</key>
      <true/>
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSIncludesSubdomains</key>
      <true/>
      <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSAllowsArbitraryLoadsInWebContent</key>
      <true/>


      Code below



          let link = URL(string: "https://stackoverflow.com")!
      let req = URLRequest(url: link)
      webView.navigationDelegate = self
      webView.uiDelegate = self
      self.view.addSubview(webView)
      self.view.bringSubview(toFront: webView)
      self.webView!.load(req)


      I am extremely confused why any web page does not load



      I have tried http and https



      I have tired multiple websites, no luck



      it just stays on a blank white screen










      share|improve this question














      I have searched for a few hours now and tried many solutions and none seem to work.



      I have disabled my AVG web shield, added this to my plist under App transport



          <key>NSAllowsArbitraryLoads</key>
      <true/>
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSIncludesSubdomains</key>
      <true/>
      <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <key>NSAllowsArbitraryLoadsInWebContent</key>
      <true/>


      Code below



          let link = URL(string: "https://stackoverflow.com")!
      let req = URLRequest(url: link)
      webView.navigationDelegate = self
      webView.uiDelegate = self
      self.view.addSubview(webView)
      self.view.bringSubview(toFront: webView)
      self.webView!.load(req)


      I am extremely confused why any web page does not load



      I have tried http and https



      I have tired multiple websites, no luck



      it just stays on a blank white screen







      ios swift xcode wkwebview






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 27 '18 at 22:04









      EasyEasy

      1




      1
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Your code works in my playground, so something is wrong with how you are creating the web view or the constraints. See example:



          import UIKit
          import PlaygroundSupport
          import WebKit

          class ViewController: UIViewController {
          override func viewDidLoad() {
          super.viewDidLoad()
          let webView = WKWebView()
          view.addSubview(webView)
          webView.translatesAutoresizingMaskIntoConstraints = false
          webView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
          webView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
          webView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
          webView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true

          let link = URL(string: "https://stackoverflow.com")!
          let req = URLRequest(url: link)
          webView.load(req)
          view.setNeedsLayout()
          }
          }

          PlaygroundPage.current.needsIndefiniteExecution = true
          PlaygroundPage.current.liveView = ViewController()





          share|improve this answer































            0














            I get this on OSX apps and works for that go to general app settings, sandbox mode turn on and off again. Works every time for me on OSX apps






            share|improve this answer
























            • OSX apps have sandbox, IOS always has sandbox enabled you cannot disable it :/

              – Easy
              Nov 28 '18 at 3:05











            • Sorry my bad, hope you get it sorted

              – Slanger
              Nov 29 '18 at 9:56











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53508919%2fxcode-wkwebview-ios-wont-load-webpage-white-screen%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Your code works in my playground, so something is wrong with how you are creating the web view or the constraints. See example:



            import UIKit
            import PlaygroundSupport
            import WebKit

            class ViewController: UIViewController {
            override func viewDidLoad() {
            super.viewDidLoad()
            let webView = WKWebView()
            view.addSubview(webView)
            webView.translatesAutoresizingMaskIntoConstraints = false
            webView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
            webView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
            webView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
            webView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true

            let link = URL(string: "https://stackoverflow.com")!
            let req = URLRequest(url: link)
            webView.load(req)
            view.setNeedsLayout()
            }
            }

            PlaygroundPage.current.needsIndefiniteExecution = true
            PlaygroundPage.current.liveView = ViewController()





            share|improve this answer




























              0














              Your code works in my playground, so something is wrong with how you are creating the web view or the constraints. See example:



              import UIKit
              import PlaygroundSupport
              import WebKit

              class ViewController: UIViewController {
              override func viewDidLoad() {
              super.viewDidLoad()
              let webView = WKWebView()
              view.addSubview(webView)
              webView.translatesAutoresizingMaskIntoConstraints = false
              webView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
              webView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
              webView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
              webView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true

              let link = URL(string: "https://stackoverflow.com")!
              let req = URLRequest(url: link)
              webView.load(req)
              view.setNeedsLayout()
              }
              }

              PlaygroundPage.current.needsIndefiniteExecution = true
              PlaygroundPage.current.liveView = ViewController()





              share|improve this answer


























                0












                0








                0







                Your code works in my playground, so something is wrong with how you are creating the web view or the constraints. See example:



                import UIKit
                import PlaygroundSupport
                import WebKit

                class ViewController: UIViewController {
                override func viewDidLoad() {
                super.viewDidLoad()
                let webView = WKWebView()
                view.addSubview(webView)
                webView.translatesAutoresizingMaskIntoConstraints = false
                webView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
                webView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
                webView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
                webView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true

                let link = URL(string: "https://stackoverflow.com")!
                let req = URLRequest(url: link)
                webView.load(req)
                view.setNeedsLayout()
                }
                }

                PlaygroundPage.current.needsIndefiniteExecution = true
                PlaygroundPage.current.liveView = ViewController()





                share|improve this answer













                Your code works in my playground, so something is wrong with how you are creating the web view or the constraints. See example:



                import UIKit
                import PlaygroundSupport
                import WebKit

                class ViewController: UIViewController {
                override func viewDidLoad() {
                super.viewDidLoad()
                let webView = WKWebView()
                view.addSubview(webView)
                webView.translatesAutoresizingMaskIntoConstraints = false
                webView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
                webView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
                webView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
                webView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true

                let link = URL(string: "https://stackoverflow.com")!
                let req = URLRequest(url: link)
                webView.load(req)
                view.setNeedsLayout()
                }
                }

                PlaygroundPage.current.needsIndefiniteExecution = true
                PlaygroundPage.current.liveView = ViewController()






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 27 '18 at 23:54









                Josh HomannJosh Homann

                8,45911219




                8,45911219

























                    0














                    I get this on OSX apps and works for that go to general app settings, sandbox mode turn on and off again. Works every time for me on OSX apps






                    share|improve this answer
























                    • OSX apps have sandbox, IOS always has sandbox enabled you cannot disable it :/

                      – Easy
                      Nov 28 '18 at 3:05











                    • Sorry my bad, hope you get it sorted

                      – Slanger
                      Nov 29 '18 at 9:56
















                    0














                    I get this on OSX apps and works for that go to general app settings, sandbox mode turn on and off again. Works every time for me on OSX apps






                    share|improve this answer
























                    • OSX apps have sandbox, IOS always has sandbox enabled you cannot disable it :/

                      – Easy
                      Nov 28 '18 at 3:05











                    • Sorry my bad, hope you get it sorted

                      – Slanger
                      Nov 29 '18 at 9:56














                    0












                    0








                    0







                    I get this on OSX apps and works for that go to general app settings, sandbox mode turn on and off again. Works every time for me on OSX apps






                    share|improve this answer













                    I get this on OSX apps and works for that go to general app settings, sandbox mode turn on and off again. Works every time for me on OSX apps







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 28 '18 at 1:06









                    Slanger Slanger

                    11




                    11













                    • OSX apps have sandbox, IOS always has sandbox enabled you cannot disable it :/

                      – Easy
                      Nov 28 '18 at 3:05











                    • Sorry my bad, hope you get it sorted

                      – Slanger
                      Nov 29 '18 at 9:56



















                    • OSX apps have sandbox, IOS always has sandbox enabled you cannot disable it :/

                      – Easy
                      Nov 28 '18 at 3:05











                    • Sorry my bad, hope you get it sorted

                      – Slanger
                      Nov 29 '18 at 9:56

















                    OSX apps have sandbox, IOS always has sandbox enabled you cannot disable it :/

                    – Easy
                    Nov 28 '18 at 3:05





                    OSX apps have sandbox, IOS always has sandbox enabled you cannot disable it :/

                    – Easy
                    Nov 28 '18 at 3:05













                    Sorry my bad, hope you get it sorted

                    – Slanger
                    Nov 29 '18 at 9:56





                    Sorry my bad, hope you get it sorted

                    – Slanger
                    Nov 29 '18 at 9:56


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53508919%2fxcode-wkwebview-ios-wont-load-webpage-white-screen%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                    Calculate evaluation metrics using cross_val_predict sklearn

                    Insert data from modal to MySQL (multiple modal on website)