这个问题与以下内容完全相同:
无法转换类型'UINavigationController'(0x37aa0dc8)t的值
我想调用我的DetailViewController的方法。但是他们崩溃并显示上面提到的错误
func move()
{
let VC = storyboard!.instantiateViewController(withIdentifier: "PDF") as! PDFViewController
self.navigationController?.pushViewController(VC, animated: true)
}
将视图控制器转换为导航控制器,并访问其topViewController
属性。
let pdfVC = (storyboard!.instantiateViewController(withIdentifier: "PDF") as! UINavigationController).topViewController as! PDFViewController
self.navigationController?.pushViewController(pdfVC, animated: true)