UIButton 创建错误 - "unrecognized selector sent to instance"

UIButton creating error - "unrecognized selector sent to instance"

我已经使用此代码向我的视图添加了一个按钮,但是它出现错误 "unrecognized selector sent to instance" 并导致应用程序崩溃。

有人知道这是为什么吗?

非常感谢!

       let button: UIButton = UIButton(frame: CGRectMake(100, 400, 100, 50))
        button.backgroundColor = UIColor.clearColor()
        button.setTitle("go Back", forState: UIControlState.Normal)
        button.addTarget(self, action:  "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
        self.view.addSubview(button)


    }

    func buttonAction(sender: UIButton!) {

        println("SegueSTGB")
        performSegueWithIdentifier("SegueSTGB", sender: self)

    }

你应该修改addTarget:

button.addTarget(self, action:Selector("buttonAction:"), forControlEvents: UIControlEvents.TouchUpInside)