LoginSignup
19
8

More than 3 years have passed since last update.

iOS13で、presentで画面遷移をした際に遷移前の画面に戻れてしまう問題について

Last updated at Posted at 2019-09-26

問題

iOS13で、presentで画面遷移をした際、全画面表示されなくなっている。
そして、画面を下にスワイプすると、簡単に遷移前の画面に戻れてしまう。

IMG_4871.png

原因

iOS13ではpresentでモーダル表示する際のmodalPresentationStyleのデフォルト値が.pageSheetに変更されたため。

解決法

遷移先のViewControllermodalPresentationStyle.fullScreenを設定すればOK。

ViewController.swift
let loginStoryBoard: UIStoryboard = UIStoryboard(name: "Login", bundle: nil)
let viewController = loginStoryBoard.instantiateInitialViewController()
viewController?.modalPresentationStyle = .fullScreen
self.present(viewController!, animated: true, completion: nil)

すると、以下のように全画面表示され、スワイプしても遷移前の画面に戻れなくなります。

IMG_4872.png

参考

iOS - ios13のプロジェクトでpresentすると遷移前の画面に戻れてしまう|teratail
viewcontroller - Presenting modal in iOS 13 fullscreen - Stack Overflow

19
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
8