Could not cast value of type 'UITableViewController' to 'UINavigationController'

早过忘川 提交于 2019-12-06 06:25:16

Actually, the segue.destinationViewController isn't the navigation controller; rather, it is the view controller that the segue is opening. Since UITableViewController is a subclass of UIViewController, this code should work just fine:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
    if (segue.identifier == "segueLogWaterData") {
        let dest = segue.destinationViewController as! WaterDataViewController
        //Assign to dest's properties
    }
}

nav.topViewController is a UITableViewController. Apparently, WaterDataViewController is not a subclass of UITableViewController.

Do you mean to be using rootViewController instead?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!