swift - 推送没有情节提要的 ViewController
问题描述
我尝试像这样(Swift 4)从主 ViewController 推送视图控制器:
@objc func childAction(sender: UIButton!) {
print("Child button tapped")
let vc = childDetailViewController()
self.navigationController?.pushViewController(vc, animated: true)
}
文本被打印,但 viewController 没有被推送。我错过了什么?
解决方案
可能self.navigationController
是nil
。
尝试呈现它:self.present(vc, animated: true)
UPD
此外,如果它没有帮助,请尝试临时更改您的childDetailViewController
to UIViewController()
,看看会发生什么。如果您在点击后看到空白屏幕,则问题出在 childDetailViewController
推荐阅读
- shader - 使用 SPIRV-Reflect,我怎么知道来自不同着色器的两个描述符绑定实际上是指同一个缓冲区?
- java - 如何忽略跳过锁定以更新针对 junit 测试用例的内存数据库的自定义查询
- c++ - 使用 C++ 和 CUDA 在 GPU 上读取视频
- azure - 如何在同时更新 Azure 资源(例如使用 terraform)时找出 409 冲突的根本原因?
- c# - 抛出异常:System.Data.dll 中的“System.ArgumentException”
- microsoft-graph-api - b2cAuthenticationMethodsPolicy 方法的权限不足
- javascript - jQuery复制到剪贴板,手动输入没有ID的文本
- r - 如何测试依赖于 menu() 用户输入的函数
- android - @BeforeAll 在 JUnit5 中没有按预期运行
- python - 无法在 virtualbox 中使用 spyder (Python) 访问 Director 中的文件