我有以下旨在更改 View 的代码。当我的“UITableViewRowAction”被选中并打算导航到不同的 UITableViewController 时,将执行此代码。但是,我收到以下错误,我不明白我做错了什么。
let storyBoard: UIStoryboard = UIStoryboard.init(name: "Main", bundle: nil)
let selectFolderViewController = storyBoard.instantiateViewController(withIdentifier: "SaveArticleTableViewController") as! SaveArticleTableViewController
self.navigationController?.pushViewController(selectFolderViewController, animated: true)
我在控制台中得到的错误是:
Could not cast value of type 'UINavigationController' (0x106f5c898) to 'lifesci_PubMed.SaveArticleTableViewController' (0x104dbb658).
我所有的 ViewController 都嵌入在导航 Controller 中
最佳答案
很可能是你没有在 Storyboard 中正确设置 view controller 的自定义类。这是一张图片...
您将在该插槽中键入“SaveArticleTableViewController”。
很可能您还有其他问题,但这会让您继续前进。
关于ios - 使用 Swift 以编程方式更改 View - 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46869264/