5
The screen displayed as a modal (sheet) is not a problem of Xcode 11, this behavior happens from iOS 13 and derivatives (iPadOS) as announced in WWDC’s talk of 2019 Modernizing Your UI for iOS 13, starts at 09:45 lasts a little more than 10 minutes.
What changed was the property modalPresentationStyle has assumed the default value .automatic this displays the viewcontroller as a modal and also adds a close Gesture that is triggered by clicking and dragging down the screen.
Resolution with storyboard/following
Access the storyboard, select the following and in the inspector attribute (blue icon at the top), change the properties:
kindofpushforPresent ModallyPresentationofSame As DestinationforFull Screen
Programmatic resolution
1) To let the screen fullscreen as in iOS 12 just set modalPresentationStyle as .fullScreen in the viewcontroller that will be displayed.
@IBAction func mainClick(_ sender: Any) {
if let controller = self.storyboard?.instantiateViewController(withIdentifier: "DetailsViewController") {
controller.modalPresentationStyle = .fullScreen
present(controller, animated: true)
}
}
2) You can get around the situation by avoiding the Gesture that hides the view controller by setting isModalInPresentation as true, the screen will still have visual of a tab.
@IBAction func mainClick(_ sender: Any) {
if let controller = self.storyboard?.instantiateViewController(withIdentifier: "DetailsViewController") {
controller.isModalInPresentation = true
present(controller, animated: true)
}
}
Delegates
Three new methods are offered to handle this new Esture through UIAdaptivePresentationControllerDelegate.
presentationControllerDidAttemptToDismiss: Activated by pulling the tab only whenisModalInPresentationfortrue.presentationControllerDidDismiss: Activated when the tab has already disappeared andisModalInPresentationforfalse.presentationControllerWillDismiss: Activated when starting Esture (click and drag) andisModalInPresentationforfalse.
Example:
import UIKit
class DetailsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.presentationController?.delegate = self
self.isModalInPresentation = false
}
}
extension DetailsViewController: UIAdaptivePresentationControllerDelegate {
func presentationControllerDidAttemptToDismiss(_ presentationController: UIPresentationController) {
print("Ao puxar a aba")
}
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
print("Quando a aba já sumiu")
}
func presentationControllerWillDismiss(_ presentationController: UIPresentationController) {
print("No inicio do gesture")
}
}



It displays the screen as a modal? take a test, run the app, see if you can drag down that modal and if it closes the screen.
– rray
If you drag down this "modal" screen, it is just this blue screen of the background. As amazing as it looks the same app opens perfectly in Xcode ver.10
– AndersonSilva
This happens because Apple changed the modalpresentation in iOS13, it is not an Xcode problem. Need to change it from Automatic q is the default in iOS 13 to fullscreen.
– rray
It worked out really well
– AndersonSilva
Before: -------- Let storyboard = Uistoryboard(name: "Main", Bundle: nil) Let vc = storyboard.instantiateViewController(withIdentifier: "navController") as Uiviewcontroller self(vc, Animated: true, present: nil) --------- After: --------- Let storyboard = Uistoryboard(name: "Main", Bundle: nil) Let vc = storyboard.instantiateViewController(withIdentifier: "navController") as Uiviewcontroller vc.modalPresentationStyle = . fullscreen self.present(vc, Animated: true, Completion: nil) ---------
– AndersonSilva