Resized screen after upgrading Xcode to version 11

Asked

Viewed 124 times

5

After upgrading the Xcode to version 11, the App developed for Ipad does not behave in a maximized way on the screen when running, both in the simulator and on the device, but the storyboard is perfect.

No Xcode: No Xcode:

In the Simulator or Ipad: No Simulador

  • 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.

  • 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

  • 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.

  • It worked out really well

  • 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) ---------

1 answer

4

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:

  • kind of push for Present Modally
  • Presentation of Same As Destination for Full Screen

inserir a descrição da imagem aqui

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 when isModalInPresentation for true.

  • presentationControllerDidDismiss: Activated when the tab has already disappeared and isModalInPresentation for false.

  • presentationControllerWillDismiss: Activated when starting Esture (click and drag) and isModalInPresentation for false.

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")
    }
}

Recommended reading:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.