我试图呈现一个从底部到顶部显示的视图。这是我的代码
let myPageViewController = storyboard?.instantiateViewController(withIdentifier: "myPageViewControllerID") as! MyPageViewController
myPageViewController.modalPresentationStyle = .fullScreen
let navController = UINavigationController(rootViewController: myPageViewController)
navigationController?.present(navController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
尽管我正在使用.fullScreen,但该视图并未全屏显示。我尝试使用 peformSegue 来显示此代码的视图
self.performSegue(withIdentifier: "myPageViewSegue", sender: nil)
Run Code Online (Sandbox Code Playgroud)
页面全屏显示,但从左到右,而不是从下到上。
我试过的第三个代码是这个
let detailVC = MyPageViewController()
let navigationController = UINavigationController(rootViewController: detailVC)
navigationController.modalPresentationStyle = .fullScreen
present(detailVC, animated: true)
Run Code Online (Sandbox Code Playgroud)
在这里我得到一个错误Application tried to present modally an active controller。我试图在消失 MyPageViewController 时添加 self.dismiss 但它没有帮助。