我发现了一个与我最相似的问题,但没有得到彻底的回答。如果有人能帮助我,那就太好了。我发现类似问题的地方是here .
我很清楚 func test()
是 "test"
而 test(object:AnyObject)
是 "测试:"
。感谢this .
那么2个参数呢? swift 不能为“action:”做 2 个参数吗?
func popoverSelectedCode (code:AnyObject, desc:AnyObject)
我尝试通过以下几种不同的方式对其进行测试,但无济于事:
action: "popoverSelectedCode:,"
action: "popoverSelectedCode:,:"
action: "popoverSelectedCode: :"
action: "popoverSelectedCode: , :"
我才使用 Swift 一周左右,所以请多关照。
已编辑 这是代码的简短片段
@IBAction func securityQuestButtonClicked (sender:AnyObject)
{
cellButton = sender as? UIButton;
var comboDescListArray = TableRoutine.loadCombobox("MobileQuestion")
var codeObject : NSArray = comboDescListArray[0] as NSArray;
var descObject : NSArray = comboDescListArray[1] as NSArray;
var selectionTVC = CPSelectionTVC(style:UITableViewStyle.Plain, codeArray:codeObject, descArray:descObject, target:self, action: "popoverSelectedCode::", widthForViewInPopover:650)
let navCtl = UINavigationController.init(rootViewController:selectionTVC)
popoverController = UIPopoverController.init(contentViewController:navCtl)
var contentHeight : CGFloat = CGFloat (UInt(selectionTVC.navigationTitleHeight) + UInt(selectionTVC.rowCount()) * UInt(selectionTVC.cellHeight))
popoverController?.popoverContentSize = CGSizeMake(400.0, contentHeight)
popoverController?.presentPopoverFromRect(sender.bounds, inView:sender as UIView, permittedArrowDirections:UIPopoverArrowDirection.Up, animated:true)
}
弹出窗口出现,但是在选择时,它只是挂起。
最佳答案
只是关于 Swift 2.2 的注释。 您现在可以将选择器键入为
#selector(popoverSelectedCode(_:desc:)
关于swift - Action 的多个参数/参数 - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27916638/