Ios 无法调用'';参数列表类型为'';
这一行:Ios 无法调用'';参数列表类型为'';,ios,swift,Ios,Swift,这一行: appDelegate.navigationController.pushViewControllerOnTopOfEverything(controller) 导致此错误的原因: Cannot invoke 'pushViewControllerOnTopOfEverything' with an argument list of type '(VUPickerController!)' 以下是完整的功能: func onSortTapped() { if se
appDelegate.navigationController.pushViewControllerOnTopOfEverything(controller)
导致此错误的原因:
Cannot invoke 'pushViewControllerOnTopOfEverything' with an argument list of type '(VUPickerController!)'
以下是完整的功能:
func onSortTapped() {
if self.pickerModel == nil {
self.pickerModel = VUPickerModel.newOrExistingPickerModelForKey(VUPickerModelKeyType.ShowsSort)
}
var controller = VUPickerController(model: self.pickerModel) { (selectionChanged) in
if selectionChanged {
self.pickerModel?.archiveWithModelKeyType(VUPickerModelKeyType.ShowsSort)
let userSelections = self.pickerModel!.selectedRows()
let sectionItem = userSelections![0] as! VUPickerSectionItem
self.leftGenreBar?.genreName = sectionItem.title
}
}
let appDelegate = UIApplication.sharedApplication().delegate
appDelegate.navigationController.pushViewControllerOnTopOfEverything(controller)
}
navigationController
是一个用Obj-C编写的自定义UIViewController
,而PushViewControllerOnTopofearthing
的定义如下:
- (void)pushViewControllerOnTopOfEverything:(UIViewController *)viewController;
另外,VUPickerController
是从UIViewController
子类化的
onSortTapped()
最初是用Obj-C编写的,我正在尝试做一个简单的翻译,但我遗漏了一些东西
我确实尝试了对
UIViewController
进行强制转换:
appDelegate.navigationController.pushViewControllerOnTopOfEverything(controller as! UIViewController)
但也有一个类似的错误:
Cannot invoke 'pushViewControllerOnTopOfEverything' with an argument list of type '(UIViewController)'
编辑 当我尝试:
po appDelegate.navigationController
在调试控制台中,我得到:
error: <EXPR>:1:13: error: type of expression is ambiguous without more context
我得到:
Printing description of appDelegate:
Optional(<AppDelegate: 0x7f81a2d1cc40>)
打印appDelegate的说明:
可选()
而
navigationController
是appDelegate的一个属性,在原始Obj-CappDelegate.h
文件中声明 你试过将pushViewControllerOnTopOfEverything与普通的UIViewController一起使用吗?@Icaro刚刚尝试过,并且出现了同样的错误。代码中没有任何其他pushViewControllerOnTopOfEverything会让swift感到困惑?
Printing description of appDelegate:
Optional(<AppDelegate: 0x7f81a2d1cc40>)