Swift Playgrounds: Rendering Local html file in WebKit works on simulator but not on deviceDetect if app is being built for device or simulator in SwiftiOS Webkit not working on device, but works on simulator at swiftRead file in swift, iOS playgroundSwift Playground - Files are not readableWhy is my Printable implementation not working in Swift playground?Xcode playgrounds can't access swift files in Sources folderHow to detect tableView cell touched or clicked in swiftIs it possible to simulate device orientation in a playground?How do Swift Playgrounds Work?Swift Error - Use of undeclared type 'cell' - Collection View
Can a UK national work as a paid shop assistant in the USA?
Why does the Starter Set wizard have six spells in their spellbook?
Python program for fibonacci sequence using a recursive function
Why did Jon Snow do this immoral act if he is so honorable?
Is it legal to have an abortion in another state or abroad?
Are there any German nonsense poems (Jabberwocky)?
Why was this character made Grand Maester?
What are these clip-like things?
Cardio work for Muay Thai fighters
Is "vegetable base" a common term in English?
How to teach an undergraduate course without having taken that course formally before?
Second map without labels
Why did other houses not demand this?
Burned out due to current job, Can I take a week of vacation between jobs?
Are cells guaranteed to get at least one mitochondrion when they divide?
If I arrive in the UK, and then head to mainland Europe, does my Schengen visa 90 day limit start when I arrived in the UK, or mainland Europe?
Possibility of faking someone's public key
Freedom of Speech and Assembly in China
How did the Unsullied find out that Jon did this?
Is there a simple example that empirical evidence is misleading?
Shorten or merge multiple lines of `&> /dev/null &`
Heat lost in ideal capacitor charging
shell script is not executed after adding it as a crontab job
Why sampling a periodic signal doesn't yield a periodic discrete signal?
Swift Playgrounds: Rendering Local html file in WebKit works on simulator but not on device
Detect if app is being built for device or simulator in SwiftiOS Webkit not working on device, but works on simulator at swiftRead file in swift, iOS playgroundSwift Playground - Files are not readableWhy is my Printable implementation not working in Swift playground?Xcode playgrounds can't access swift files in Sources folderHow to detect tableView cell touched or clicked in swiftIs it possible to simulate device orientation in a playground?How do Swift Playgrounds Work?Swift Error - Use of undeclared type 'cell' - Collection View
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to render a WebKit view using a local HTML file i have on my playground but it renders it on the simulator but it doesn't on the playground.
My code looks something like this:
import UIKit
import Foundation
import PlaygroundSupport
import WebKit
public class Plastic : UIViewController, WKUIDelegate
var webView: WKWebView!
public override func loadView()
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
public override func viewDidLoad()
super.viewDidLoad()
let url = Bundle.main.url(forResource: "plastic", withExtension: "html")!
webView.loadFileURL(url, allowingReadAccessTo: url)
let myRequest = URLRequest(url: url)
webView.load(myRequest)
@objc func notification()
PlaygroundPage.current.liveView = Banana()
Can this be a bug in playgrounds for local HTML files not to be rendered? This is odd behaviour for me and I don't know how to solve it.
swift webkit swift-playground
add a comment |
I'm trying to render a WebKit view using a local HTML file i have on my playground but it renders it on the simulator but it doesn't on the playground.
My code looks something like this:
import UIKit
import Foundation
import PlaygroundSupport
import WebKit
public class Plastic : UIViewController, WKUIDelegate
var webView: WKWebView!
public override func loadView()
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
public override func viewDidLoad()
super.viewDidLoad()
let url = Bundle.main.url(forResource: "plastic", withExtension: "html")!
webView.loadFileURL(url, allowingReadAccessTo: url)
let myRequest = URLRequest(url: url)
webView.load(myRequest)
@objc func notification()
PlaygroundPage.current.liveView = Banana()
Can this be a bug in playgrounds for local HTML files not to be rendered? This is odd behaviour for me and I don't know how to solve it.
swift webkit swift-playground
add a comment |
I'm trying to render a WebKit view using a local HTML file i have on my playground but it renders it on the simulator but it doesn't on the playground.
My code looks something like this:
import UIKit
import Foundation
import PlaygroundSupport
import WebKit
public class Plastic : UIViewController, WKUIDelegate
var webView: WKWebView!
public override func loadView()
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
public override func viewDidLoad()
super.viewDidLoad()
let url = Bundle.main.url(forResource: "plastic", withExtension: "html")!
webView.loadFileURL(url, allowingReadAccessTo: url)
let myRequest = URLRequest(url: url)
webView.load(myRequest)
@objc func notification()
PlaygroundPage.current.liveView = Banana()
Can this be a bug in playgrounds for local HTML files not to be rendered? This is odd behaviour for me and I don't know how to solve it.
swift webkit swift-playground
I'm trying to render a WebKit view using a local HTML file i have on my playground but it renders it on the simulator but it doesn't on the playground.
My code looks something like this:
import UIKit
import Foundation
import PlaygroundSupport
import WebKit
public class Plastic : UIViewController, WKUIDelegate
var webView: WKWebView!
public override func loadView()
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
public override func viewDidLoad()
super.viewDidLoad()
let url = Bundle.main.url(forResource: "plastic", withExtension: "html")!
webView.loadFileURL(url, allowingReadAccessTo: url)
let myRequest = URLRequest(url: url)
webView.load(myRequest)
@objc func notification()
PlaygroundPage.current.liveView = Banana()
Can this be a bug in playgrounds for local HTML files not to be rendered? This is odd behaviour for me and I don't know how to solve it.
swift webkit swift-playground
swift webkit swift-playground
asked Mar 23 at 23:14
MatejMeckaMatejMecka
1,11411825
1,11411825
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The Art of the Bodge. This is one way i fixed it to work on a device. Not the best way but it does the job in the short time I had.
if let url = Bundle.main.path(forResource: "pla", ofType: "html")
do
let contents = try String(contentsOfFile: url)
webView.loadHTMLString(contents, baseURL: nil)
catch
return
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%2f55319240%2fswift-playgrounds-rendering-local-html-file-in-webkit-works-on-simulator-but-no%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The Art of the Bodge. This is one way i fixed it to work on a device. Not the best way but it does the job in the short time I had.
if let url = Bundle.main.path(forResource: "pla", ofType: "html")
do
let contents = try String(contentsOfFile: url)
webView.loadHTMLString(contents, baseURL: nil)
catch
return
add a comment |
The Art of the Bodge. This is one way i fixed it to work on a device. Not the best way but it does the job in the short time I had.
if let url = Bundle.main.path(forResource: "pla", ofType: "html")
do
let contents = try String(contentsOfFile: url)
webView.loadHTMLString(contents, baseURL: nil)
catch
return
add a comment |
The Art of the Bodge. This is one way i fixed it to work on a device. Not the best way but it does the job in the short time I had.
if let url = Bundle.main.path(forResource: "pla", ofType: "html")
do
let contents = try String(contentsOfFile: url)
webView.loadHTMLString(contents, baseURL: nil)
catch
return
The Art of the Bodge. This is one way i fixed it to work on a device. Not the best way but it does the job in the short time I had.
if let url = Bundle.main.path(forResource: "pla", ofType: "html")
do
let contents = try String(contentsOfFile: url)
webView.loadHTMLString(contents, baseURL: nil)
catch
return
answered Mar 24 at 9:25
MatejMeckaMatejMecka
1,11411825
1,11411825
add a comment |
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%2f55319240%2fswift-playgrounds-rendering-local-html-file-in-webkit-works-on-simulator-but-no%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