Post

Replies

Boosts

Views

Activity

Swift Playgrounds on iPad : load a html page
Hi, I have installed Swift Playgrounds on my iPad and I would like to create an app that displays a webpage (html). I tried several code found on the web, like this below, but does not work. import WebKit class ViewController: UIViewController, WKUIDelegate { var webView: WKWebView! override func loadView() { let webConfiguration = WKWebViewConfiguration() webView = WKWebView(frame: .zero, configuration: webConfiguration) webView.uiDelegate = self view = webView } override func viewDidLoad() { super.viewDidLoad() let myURL = URL(string:"https://www.apple.com") let myRequest = URLRequest(url: myURL!) webView.load(myRequest) }} Is it possible to create an app on Swift Playgrounds for iPad that lauch a html page in a webView ? Thanks for your help.
5
0
2.4k
Apr ’22
Constrain a WKView to Safe Area
Hi, I have created a simple WKView with a local webpage which is loaded. I have a problem with display of the html document : I would like to constrain the view of the page to the Safe Area, and not to Super View. At this moment, when I scroll down, html page is visible at the top of the screen, in the status bar, which is not very beautiful on last iPhones (mix of text of my page and device hours/network status/battery status...). I tested multiple solutions, in info file, but I am unable to suppress the transparency of this status bar or constrain webpage to fit only in Safe Area. Could you help me ? import UIKit import WebKit class ViewController: UIViewController, WKUIDelegate { var webView: WKWebView! override func loadView() { let webConfiguration = WKWebViewConfiguration() webView = WKWebView(frame: .zero, configuration: webConfiguration) webView.uiDelegate = self view = webView } override func viewDidLoad() { super.viewDidLoad() if let indexURL = Bundle.main.url(forResource: "index", withExtension: "html", subdirectory: "files") { self.webView.loadFileURL(indexURL, allowingReadAccessTo: indexURL) } }}
3
0
1.6k
May ’22
How make a Webview fits Safe Area on all devices
Hi, I have created a Webview and I want it to fit the Safe Area for all devices (iPhone and iPad). I tried, I think, all options in the View panel (Show, Arrange, Autoresizing, Layout Margins...), but I can't find a configuration that resizes and fits my Webview to Safe Area for all devices, with or without Superview and with different screen sizes. Thanks for your help.
0
0
1.3k
May ’22
Geolocation in webview app : how to change prompt text ?
Hi, I am creating an app for iOS with Xcode, which displays html files in a webview. For a page, I need geolocation of device and for this, I use geolocation HTML5. Here is a part of my code : function detect_position(){ if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( ... ) This works, but each time I open this page in my app (tested on simulator and physical device), I have this prompt :  I am unable to change the text of this prompt to avoid this long folders tree. Any idea ? Thanks for your help.
0
0
856
May ’22