ios - 全屏显示视图不起作用
问题描述
我试图呈现一个从底部到顶部显示的视图。这是我的代码
let myPageViewController = storyboard?.instantiateViewController(withIdentifier: "myPageViewControllerID") as! MyPageViewController
myPageViewController.modalPresentationStyle = .fullScreen
let navController = UINavigationController(rootViewController: myPageViewController)
navigationController?.present(navController, animated: true, completion: nil)
尽管我正在使用.fullScreen
,但视图并未全屏显示。我尝试使用 peformSegue 显示此代码的视图
self.performSegue(withIdentifier: "myPageViewSegue", sender: nil)
页面以全屏显示,但从左到右而不是从下到上。
我尝试的第三个代码是这个
let detailVC = MyPageViewController()
let navigationController = UINavigationController(rootViewController: detailVC)
navigationController.modalPresentationStyle = .fullScreen
present(detailVC, animated: true)
在这里我得到一个错误Application tried to present modally an active controller
。我试图在 MyPageViewController 消失时添加 self.dismiss 但它没有帮助。
解决方案
问题可能是你没有展示你正在展示详细 vc 的 navigationController,使用这个
'let detailVC = MyPageViewController()
let navigationController = UINavigationController(rootViewController: detailVC)
navigationController.modalPresentationStyle = .fullScreen
present(navigationController, animated: true)'
如果问题仍然存在,请使用
navigationController.modalPresentationStyle = .overCurrentContext
推荐阅读
- azure - 在 Graph 中检索照片时从 Microsoft 获取“AuthenticationError”
- python - 如何从单词边界中排除逗号
- celery - 在客户端/生产者上记录 Celery
- git - 删除 Git 提交
- python - “设置全局变量”或“设置套件变量”关键字在机器人框架中不起作用
- python - 如何根据函数输出写入单独的列
- java - 访问由 Spring 的类转换器创建的对象上的 getter 时出现 ArrayIndexOutOfBoundsException
- python - 如何打开从 OracleDB 导出的 .xlsx 文件?
- excel - 使用 Excel VBA 解析 PDF 文档时 RPC 失败
- android - 何时需要将 RC 代码更新到 Android Q?