1
我在柜台工作。我想在60秒过后停止工作。对于这一点,我用这个代码:Swift - 在函数中使用IBOutlet和IBAction?
class FirstViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//calling the wait function
self.callForWait()
}
func game(){
var score : Int = 0
@IBOutlet weak var afficheurScore: UILabel!
@IBAction func boutonPlus(sender: UIButton) {
score = score + 1
afficheurScore.text = "\(score)"
}
}
func callForWait(){
//setting the delay time 60secs.
let delay = 60 * Double(NSEC_PER_SEC)
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(time, dispatch_get_main_queue()) {
//call the method which have the steps after delay.
self.stepsAfterDelay()
}
}
func stepsAfterDelay(){
//your code after delay takes place here...
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
boutonPlus是一个按钮,当我点击,afficheurScore,一个简单的标签说(数+ 1)。
在我的游戏功能,我有这个错误:
“只有实例属性可以声明IBOutlet中/ IBAction为”
感谢您的回复,“只有实例属性可以声明IBOutlet中/ IBAction为”已经消失,但我有这样的问题:得分在游戏功能声明,IBAction为不有访问权。 – 2015-03-31 07:39:22
哪个问题?你只说出口/行动问题... – 2015-03-31 07:40:34
是的,真的,谢谢你:)。 – 2015-03-31 07:43:02