emn*_*a87 0 uiviewcontroller ios swift
我试图呈现一个从底部到顶部显示的视图。这是我的代码
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 但它没有帮助。
问题可能是你没有展示 navigationController 你正在展示细节 vc,使用这个
'let detailVC = MyPageViewController()
let navigationController = UINavigationController(rootViewController: detailVC)
navigationController.modalPresentationStyle = .fullScreen
present(navigationController, animated: true)'
Run Code Online (Sandbox Code Playgroud)
如果问题仍然存在,请使用
navigationController.modalPresentationStyle = .overCurrentContext
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2410 次 |
| 最近记录: |