2

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.

Here is Image

jakir hussain
  • 316
  • 2
  • 18

6 Answers6

1

It was Internet issue. I was using LAN for running this App and the IP was conflicting, so when I update the IP of my iPhone the issue got fixed.

jakir hussain
  • 316
  • 2
  • 18
0

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)
biloshkurskyi.ss
  • 1,358
  • 3
  • 15
  • 34
0

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

Shezad
  • 756
  • 7
  • 14
0

For me it looks like something is above your webview. Have you debugged your view hierarchy already ?

Milander
  • 1,021
  • 11
  • 18
  • It is working fine is simulator as well as ios 6 and above so I don't thing that there is any view hierarchy issue@Milander – jakir hussain Dec 28 '17 at 06:14
0

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
cpt. Sparrow
  • 415
  • 8
  • 22
0

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"