无法将“WeatherViewController”类型的值转换为预期的参数类型“UIViewController”

问题描述 投票:0回答:1

我试图将navigationController推送到另一个视图,我收到此错误“无法将类型'WeatherViewController'的值转换为预期的参数类型'UIViewController'”

 extension RegionListViewController: SidebarViewDelegate {

  func sidebarDidSelectRow(row: Row) {
    blackScreen.isHidden = true
    blackScreen.frame = self.view.bounds
    UIView.animate(withDuration: 0.3) {
      self.sidebarView.frame=CGRect(x: 0, y: 0, width: 0, height: self.sidebarView.frame.height)
    }
    switch row {
    case .ethiopia:
      let vc = EthiopiaVC()
      self.navigationController?.pushViewController(vc, animated: true)
    case .weather:
     let wV = WeatherViewController()
      self.navigationController?.pushViewController(wV, animated: true)
    case .currency:
      print("Settings")
    case .Searchs:
      let sv = SearchViewController()
      **self.navigationController?.pushViewController(sv, animated: true)** error here
    case .feedbacks:
      print("Sign out")
    case .none:
      break

    }
  }
}
swift4.2
1个回答
0
投票

确保您的自定义视图控制器都是UIViewController的子类。

© www.soinside.com 2019 - 2024. All rights reserved.