Presenting Modal in iOS 13 Fullscreen

Presenting modal in iOS 13 fullscreen

With iOS 13, as stated in the Platforms State of the Union during the WWDC 2019, Apple introduced a new default card presentation. In order to force the fullscreen you have to specify it explicitly with:

let vc = UIViewController()
vc.modalPresentationStyle = .fullScreen //or .overFullScreen for transparency
self.present(vc, animated: true, completion: nil)

New iOS 13 Modal Presentation: Presenting Controller Doesn't Move Down

Turns out the problem was my view controller hierarchy. I was able to fix it by making the presenting view controller the root view controller of my app. First I set the background controller as the root view controller by calling

window.rootViewController = self

and then using my previous code

let controller = storyboard?.instantiateViewController(withIdentifier: "tutorial") as! TutorialController
controller.modalPresentationStyle = .pageSheet
controller.modalTransitionStyle = .coverVertical
present(controller, animated: true, completion: nil)

I presented the view controller. Thanks to everyone who tried to help!

Presenting the ViewController in full screen

In iOS 13 the default presentation style has changed. If you want iOS 12 presentation style, you can change the modalPresentationStyle to .fullScreen.

Swift Version

navigation.modalPresentationStyle = .fullScreen

Objective C

navigation.modalPresentationStyle = UIModalPresentationOverFullScreen;

Presenting modal in iOS 13 fullscreen

With iOS 13, as stated in the Platforms State of the Union during the WWDC 2019, Apple introduced a new default card presentation. In order to force the fullscreen you have to specify it explicitly with:

let vc = UIViewController()
vc.modalPresentationStyle = .fullScreen //or .overFullScreen for transparency
self.present(vc, animated: true, completion: nil)

How to present a popup view in full screen

You could try presenting with the navigation controller.

let storyboard = UIStoryboard(name: "Other", bundle: Bundle.main)

guard let popupVC = storyboard.instantiateViewController(withIdentifier: "PopUpViewController") as? PopUpViewController else {
print("PopUpViewController not found")
return
}

var navigationController = UINavigationController(rootViewController: popupVC)
navigationController.modalPresentationStyle = .fullScreen
self.present(navigationViewController, animated: true, completion: nil)

An alternative would be to use presentViewController but presentViewController will only present one viewController modally over the currently visible viewController whereas presenting with the navigationController will give the flexibility to push further components on top, providing a smoother navigation experience with go back to previous page kind of behaviour.

modalPresentationStyle default value in iOS 13

  1. UIModalPresentationStyle.automatic switches between .pageSheet and .fullScreen depending on the context in which UIViewController is presented.
  2. If you are using normal UIViewController it will default to .pageSheet.
  3. But if you are using some subclass of UIViewController like UIImagePickerController iOS expects content should in full screen mode so it will default to .fullscreen.
  4. If you are using iOS version less than 13 it will always default to .fullscreen.


Related Topics



Leave a reply



Submit