Xcode WKWebView (IOS) Wont Load Webpage, White Screen
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
add a comment |
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
add a comment |
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
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
ios swift xcode wkwebview
asked Nov 27 '18 at 22:04
EasyEasy
1
1
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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()
add a comment |
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
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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()
add a comment |
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()
add a comment |
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()
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()
answered Nov 27 '18 at 23:54
Josh HomannJosh Homann
8,45911219
8,45911219
add a comment |
add a comment |
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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