Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
[ad_1]
I’ve two ViewControllers
in my utility. One is definitely current on the Storyboard
, and it has one button to open one other ViewController
. The second ViewController
is definitely a WKWebView
that I wish to open on the button click on. Once I click on the button the WebView
simply slides on prime of the primary ViewController
however I would like it to open in Full display screen mode. So earlier than navigating I did attempt to set modalPresentationStyle
to full display screen but it surely does not appear to work in any respect.
That is how I attempt to navigate to the WebViewViewController:
@IBAction func wkWebView(_ sender: Any) {
if let url = URL(string: urlTextField.textual content ?? "https://www.google.com") {
if (!urlTextField.isHidden) {
urlTextField.endEditing(true)
}
let vc = WebViewViewController(url: url)
let navVC = UINavigationController(rootViewController: vc)
vc.modalPresentationStyle = .fullScreen;
current(navVC, animated:true)
}
}
That is the WebViewViewController code (I haven’t got it on my Storyboard, so I haven’t got any segue between the 2 ViewControllers ):
import UIKit
import WebKit
class WebViewViewController: UIViewController {
personal let webView: WKWebView = {
let preferences = WKWebpagePreferences()
preferences.allowsContentJavaScript = true;
let configurtions = WKWebViewConfiguration();
configurtions.defaultWebpagePreferences = preferences;
configurtions.allowsInlineMediaPlayback = true;
configurtions.requiresUserActionForMediaPlayback = false
let webView = WKWebView(body: .zero, configuration: configurtions)
webView.scrollView.contentInsetAdjustmentBehavior = .by no means
return webView;
}()
personal let url: URL;
init(url: URL) {
self.url = url
tremendous.init(nibName: nil, bundle: nil);
}
required init?(coder: NSCoder) {
fatalError()
}
override func viewDidLoad() {
tremendous.viewDidLoad()
view.backgroundColor = .systemBackground
view.addSubview(webView);
webView.load(URLRequest(url: url));
}
override func viewDidLayoutSubviews() {
tremendous.viewDidLayoutSubviews()
webView.body = view.bounds
}
}
How can I make the Webview ViewController to open in a fullscreen?
[ad_2]