【发布时间】:2015-04-02 09:05:34
【问题描述】:
在 Swift 中,当按下按钮时,应用程序崩溃并出现错误
没有实现 methodSignatureForSelector: -- 前面的麻烦 无法识别的选择器
在代码中,我的一个 Controller 类获取对 UIButton 的引用并添加如下目标
aButton.addTarget(self, action: "pressed:", forControlEvents: UIControlEvents.TouchUpInside)
按下的函数定义为
func pressed(sender:UIButton)
{
println("button pressed")
}
Controller 类定义如下
class MyController
{
init()
{
}
// Also here it gets the reference to the UIButton and has pressed function as well.
}
【问题讨论】:
-
非常相似的问答在这里:stackoverflow.com/questions/24415662/….