-1

Recently, I Updated my Xcode from 10.1 to 11.3, and I noticed that some of the features were change, when I ran my app on an Simulator with iOS 13, I saw that the there is a space between the status bar and the scrollview I used for the main page, please see attached images:

https://i.stack.imgur.com/uoFE7.png

https://i.stack.imgur.com/Rb0FV.png

How to fix?

Ahmad F
  • 30,560
  • 17
  • 97
  • 143

3 Answers3

2

Consider Roberto's answer if you can push view controllers. If using present:

Storyboard solution:

If you still want to use present, then change segue presentation to Full Screen in the storyboard.

enter image description here

Programmatically:

let vc = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "yourVC") as! YourVC
    vc.modalPresentationStyle = .fullScreen // add this
    self.present(vc, animated: true, completion: nil)
Keshu R.
  • 5,045
  • 1
  • 18
  • 38
1

That's because of the code you're using to present the view controller.

The method present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) will show your view controller modally. https://developer.apple.com/documentation/uikit/uiviewcontroller

If you don't want that effect, you'll have to use pushViewController(_ viewController: UIViewController, animated: Bool) https://developer.apple.com/documentation/uikit/uinavigationcontroller

IloneSP
  • 429
  • 2
  • 13
  • 1
    Changing the behavior from `present` to `push` isn't a proper solution, it doesn't make sense to change the whole behavior just for editing the presentation transition. – Ahmad F Feb 10 '20 at 11:57
0

While Roberto's answer is not entirely wrong, you can still use present(...) and achieve the desired UI by setting the presented controller's transition:

let vc = // initiate
vc.modalPresentationStyle = .fullScreen
present(vc, animation: true, completion: nil)

What you're experiencing is the new and default behaviour in iOS 13, which is pretty nice to have (you can pull down the new controller to dismiss it).

Of course, this will cause old apps that is presenting new controller this way to behave differently.

Eddie
  • 1,903
  • 2
  • 21
  • 46