我已连接UILabel
和UIButton
,但仍然是中止。请帮我解决这个问题。
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
counterLabel.text = "0"
// Do any additional setup after loading the view, typically from a nib.
}
var counterNum: Int = 0
@IBOutlet weak var counterLabel: UILabel!
@IBAction func Tap(_ sender: UIButton) {
self.counterNum += 1
self.counterLabel.text = String(self.counterNum)
}
}
答案 0 :(得分:0)
请检查故事板中的插座连接是否为counterLabel。你似乎忘记了连接插座。