无法将类型 'WeatherViewController' 的值转换为预期的参数类型 'UIViewController'
Cannot convert value of type 'WeatherViewController' to expected argument type 'UIViewController'
我正在尝试将 navigationController 推送到另一个视图,但出现此错误 "Cannot convert value of type 'WeatherViewController' to expected argument type '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
}
}
}
确保您的自定义视图控制器都是 UIViewController
的子类。
我正在尝试将 navigationController 推送到另一个视图,但出现此错误 "Cannot convert value of type 'WeatherViewController' to expected argument type '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
}
}
}
确保您的自定义视图控制器都是 UIViewController
的子类。