Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 为什么我的UIButton';谁的目标从未达到?_Swift_Uibutton - Fatal编程技术网

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)
{
}