0

Hi I have a VC with a UIWebView and a NavigationBar. When I set the Top Constraint of my webview.Top to Superview and the constant to 0, The web view does not load until the status bar and only load until the navigation bar. Why is it like that? See the following pic.

Pic

Pic2

Then if I set the webView.Top to SuperView constant to -60. I will get my ideal output. But I don't think that is the correct way. Can anyone please advice.

The ideal output:

Pic3

Pic4

Hanz Cheah
  • 761
  • 5
  • 15
  • 44

3 Answers3

0

Why you are setting the top constraint to Superview?Set the top constraint as 0 to navigation bar.It will work fine

Naren Krish
  • 259
  • 2
  • 14
  • But I want the web view load up to Status Bar, will that work? – Hanz Cheah Apr 12 '18 at 04:56
  • 2
    @HansheungCheah I can't get you, if you want to show web view upto to the status bar then u can remove the navigation bar,if navigation bar there then you need to set top constraint to the navigation bar,if navigation bar have back button so you can get back to the home page. – Naren Krish Apr 12 '18 at 05:33
  • @HansheungCheah hide navigation bar if you can't remove it, and add your own button for back navigation Hide navigation: `navigationController?.navigationBar.isHidden = true` Back action: `navigationController?.popViewController(animated: true)` – Satish Apr 12 '18 at 06:28
0

Change the constraint with superview should work it has been attached with some view. however, you need to uncheck the Adjust scrollView Insets from storyboard

Check Image.

You need to handle special case for iOS 11

Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
Dipesh Pokhrel
  • 386
  • 5
  • 20
0

I pushed the webView Top Constraint to -45 to SuperView. This will push the webView up.

I can't find any other answer.

Hanz Cheah
  • 761
  • 5
  • 15
  • 44