I am developing hybrid app using WKWebView
everything is working fine in all size simulators but when i am running code in iPhone the progress bar is showing on the screen all the time and the view is appear in status bar ,also when I scroll the screen in status bar I can see the scrolling of contents of my app.
var webview:WKWebView! let configuration = WKWebViewConfiguration() wkwebview = WKWebView(frame:self.view.frame,configuration:configuration) self.view = wkwebview wkwebview.load(req as URLRequest)
Can anyone knows what is this ?? I am using Xcode 9.2 and macOS Sierra version 10.12.6
Edited :
If I stops Internet it shows view in the iphone(fine).
It is also working fine in iphone 6 and above.
5 Answers
Answers 1
Try to be more flexible with constraints: check full descriptions with examples how to work with them.
One of possible way for you is to use NSLayoutConstraint
+ Visual Format Language
:
let webview = WKWebView(frame: self.view.frame, configuration: WKWebViewConfiguration()) webview.translatesAutoresizingMaskIntoConstraints = false self.view.addSubview(webview) webview.load(URLRequest(url: URL(string: "https://stackoverflow.com/")!)) let views = ["webview": webview] let horizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "V:|-[webview]-|", options: .alignAllCenterY, metrics: nil, views: views) let verticalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|-[webview]-|", options: .alignAllCenterX, metrics: nil, views: views) self.view.addConstraints(horizontalConstraints) self.view.addConstraints(verticalConstraints)
Answers 2
Try the below code:
override func viewDidLoad() { super.viewDidLoad() let webView = WKWebView(frame:CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height), configuration: WKWebViewConfiguration()) self.view.addSubview(webView) webView.load(URLRequest(url: URL(string: "https://google.com/")!)) }
check this screenshot --- https://i.stack.imgur.com/yVAFW.png
Answers 3
For me it looks like something is above your webview. Have you debugged your view hierarchy already ?
Answers 4
This might help. Put this code in viewWillApear
var screenViewBounds: CGRect? = wkWebView?.bounds screenViewBounds?.origin.y = 20 screenViewBounds?.size.height = screenViewBounds?.size.height - 20 wkWebView?.frame = screenViewBounds
Answers 5
Hello Jakir Hussain the solution to this question is simple. You need to go to the "General" tab and then go to "Status Bar" and select "Requires FUll Screen"
0 comments:
Post a Comment