gpt4 book ai didi

ios - 我的 .enabled 按钮 swift 代码有问题

转载 作者:行者123 更新时间:2023-11-28 16:14:09 25 4
gpt4 key购买 nike

我在玩迷你问答游戏,一切正常。现在唯一的问题是当用户完成回答按钮仍然启用的问题时。

我创建了一个函数来禁用和启用 buttons 并且我的禁用 buttons 函数正在我的 UIButton 操作中工作,但在这种情况下不起作用,我不知道是我遗漏了什么还是我做错了什么。

PS:我是 swift 代码的新手这就是我所拥有的:

 private func pickingRandomQuestion() {
if questions.count > 0 {
questionNumber = random() % questions.count
questionLabel.text = questions[questionNumber].Question
answerNumber = questions[questionNumber].Answer
imgDisplay.image = questions[questionNumber].Img

answerA.setTitle(questions[questionNumber].Answers[0], forState: .Normal)
answerB.setTitle(questions[questionNumber].Answers[1], forState: .Normal)
answerC.setTitle(questions[questionNumber].Answers[2], forState: .Normal)
answerD.setTitle(questions[questionNumber].Answers[3], forState: .Normal)

questions.removeAtIndex(questionNumber)
} else {

finishGame.hidden = false
disableButtons()
//Here is my problem
//NSLog("Done")
//NSLog(String(finalScore))


}
}

@IBAction func btnA(sender: UIButton) {
unhide()
disableButtons()
if answerNumber == 1 {
endLabel.text = "You are Right"
finalScore+=1
} else {
endLabel.text = "You are Wrong"
}
}
@IBAction func btnB(sender: UIButton) {
unhide()
disableButtons()
if answerNumber == 2 {
endLabel.text = "You got it"
finalScore+=1
} else {
endLabel.text = "You are Wrong"
}
}
@IBAction func btnC(sender: UIButton) {
unhide()
disableButtons()
if answerNumber == 3 {
endLabel.text = "You are Correct"
finalScore+=1
} else {
endLabel.text = "You are Wrong"
}
}
@IBAction func btnD(sender: UIButton) {
unhide()
disableButtons()
if answerNumber == 4 {
endLabel.text = "You are Right"
finalScore+=1
} else {
endLabel.text = "You are Wrong"
}
}
@IBAction func nextQuestion(sender: UIButton) {
pickingRandomQuestion()
hide()
enableButtons()
}

最佳答案

answerA.enabled = false

您的问题是禁用功能不起作用吗?

关于ios - 我的 .enabled 按钮 swift 代码有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39265763/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com