Presenting modal in iOS 13 fullscreen

后端 未结 30 2132
囚心锁ツ
囚心锁ツ 2020-11-21 06:48

In iOS 13 there is a new behaviour for modal view controller when being presented.

Now it\'s not fullscreen by default and when I try to slide down, the app just dis

相关标签:
30条回答
  • 2020-11-21 07:22

    Quick solution. There are already really great answers above. I am also adding my quick 2 points input, which is presented in the screenshot.

    1. If you are not using Navigation Controller then from Right Menu Inspector set the Presentation to Full Screen

    2. If you are using Navigation Controller then by default it will present full screen, you have to do nothing.

    0 讨论(0)
  • 2020-11-21 07:22

    This worked for me

    `let vc = self.storyboard?.instantiateViewController(withIdentifier: "cameraview1") as! CameraViewController

        vc.modalPresentationStyle = .fullScreen
        
    self.present(vc, animated: true, completion: nil)`
    
    0 讨论(0)
  • 2020-11-21 07:23
    class MyViewController: UIViewController {
    
        convenience init() {
            self.init(nibName:nil, bundle:nil)
            self.modalPresentationStyle = .fullScreen
        }
    
        override func viewDidLoad() {
            super.viewDidLoad()
        }
    }
    

    Rather than call self.modalPresentationStyle = .fullScreen for every view controller, you can subclass UIViewController and just use MyViewController everywhere.

    0 讨论(0)
  • 2020-11-21 07:26

    All the other answers are sufficient but for a large project like ours and where navigations are being made both in code and storyboard, it is quite a daunting task.

    For those who are actively using Storyboard. This is my advice: use Regex.

    The following format is not good for full screen pages:

    <segue destination="Bof-iQ-svK" kind="presentation" identifier="importSystem" modalPresentationStyle="fullScreen" id="bfy-FP-mlc"/>
    

    The following format is good for full screen pages:

    <segue destination="7DQ-Kj-yFD" kind="presentation" identifier="defaultLandingToSystemInfo" modalPresentationStyle="fullScreen" id="Mjn-t2-yxe"/>
    

    The following regex compatible with VS CODE will convert all Old Style pages to new style pages. You may need to escape special chars if you're using other regex engines/text editors.

    Search Regex

    <segue destination="(.*)"\s* kind="show" identifier="(.*)" id="(.*)"/>
    

    Replace Regex

    <segue destination="$1" kind="presentation" identifier="$2" modalPresentationStyle="fullScreen" id="$3"/>
    
    0 讨论(0)
  • 2020-11-21 07:27

    For Objective-C users

    Just Use this code

     [vc setModalPresentationStyle: UIModalPresentationFullScreen];
    

    Or if you want to add it particular in iOS 13.0 then use

     if (@available(iOS 13.0, *)) {
         [vc setModalPresentationStyle: UIModalPresentationFullScreen];
     } else {
         // Fallback on earlier versions
     }
    
    0 讨论(0)
  • 2020-11-21 07:27

    This worked for me:

    yourViewController.modalPresentationStyle = UIModalPresentationStyle.fullScreen

    0 讨论(0)
提交回复
热议问题