单击

时间:2015-08-29 17:01:13

标签: ios swift

    import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var buttonText: UIButton!


    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.


    }
    @IBAction func btnButtonACTION(sender: UIButton) {
        buttonText.setTitle("changetext", forState: .Normal)

    }
}

我试图通过Xcode学习快速语言的基础知识。我的想法是在点击它时更改按钮文本。但它并没有改变。我有什么遗漏的吗?

2 个答案:

答案 0 :(得分:0)

您正在使用:

buttonText.setTitle("changetext", forState: .Normal)

试试这个:

buttonText.setTitle("changetext", forState: UIControlState.Normal)

答案 1 :(得分:0)

如果要在单击按钮时更改文本,则必须将按钮连接到发送操作