【问题标题】:Could not cast value of type 'UINavigationController' Error无法转换类型“UINavigationController”错误的值
【发布时间】:2017-06-05 00:15:57
【问题描述】:

当我尝试将滑出菜单连接到另一个 ViewController 时,我遇到了 swift 3 的问题,但我遇到了 prepareforsegue 的问题。

这是我的代码。

override func prepare(for segue: UIStoryboardSegue, sender: Any?)
 {        
    let DestVC = segue.destination as! ViewControllerSlide

这是我得到错误的地方。 ^^^

    var indexPath : IndexPath = self.tableView.indexPathForSelectedRow!
    
    DestVC.varView = indexPath.row 
}

【问题讨论】:

    标签: ios swift uinavigationcontroller swift3


    【解决方案1】:

    可能您的 segue 指向 UINavigationController,请先尝试分配目的地:

    let destVC = segue.destination as! UINavigationController
    let slideVC = destVC.topViewController as! ViewControllerSlide
    //...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-02
      • 1970-01-01
      • 2018-04-22
      • 1970-01-01
      • 2023-03-23
      • 2021-09-29
      • 1970-01-01
      • 2017-12-25
      相关资源
      最近更新 更多