Swift 为什么我的UIButton';谁的目标从未达到?
我在此函数中设置的断点未被命中。原木没有被击中。中止没有发生Swift 为什么我的UIButton';谁的目标从未达到?,swift,uibutton,Swift,Uibutton,我在此函数中设置的断点未被命中。原木没有被击中。中止没有发生 如何使我的UIButton对Swift中的触摸做出响应?像这样使用,因为它需要绑定到IBAction func setupNewBinderButton() { let binderButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton binderButton.frame = CGRectMake(50, 384-25, 50, 50
如何使我的UIButton对Swift中的触摸做出响应?像这样使用,因为它需要绑定到IBAction
func setupNewBinderButton() {
let binderButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
binderButton.frame = CGRectMake(50, 384-25, 50, 50)
binderButton.setTitle("Add", forState: UIControlState.Normal)
binderButton.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
binderButton.addTarget(self, action: "addBinderTapped", forControlEvents: UIControlEvents.TouchUpInside)
binderButton.userInteractionEnabled = true
self.view.addSubview(binderButton)
}
func addBinderTapped() {
println("hi")
abort()
}
override func viewDidLoad() {
super.viewDidLoad()
setupNewBinderButton()
通过命令将此操作与您的按钮连接,并拖动到情节提要按钮以绑定此功能。无骰子。我尝试使用action:Selector(“addBinderTapped:”)和@objc func addBinderTapped(button:UIButton!){作为链接引用。因此在第二个示例中,我必须添加代码才能获得注册函数的按钮?必须有内置的方法。不幸的是,目前没有内置的方法…可能需要等待下一个SDK版本
@IBAction func addBinderTapped(sender: UIButton)
{
}