미니 퀴즈 게임에서 일하고 있습니다. 모든 것이 잘 작동합니다. 지금 당장하는 유일한 문제는 사용자가 단추가 계속 사용할 수있는 질문에 대답하는 것입니다.내 단축키 코드에 약간의 문제가 생겼습니다
내가 비활성화 및 비활성화 buttons
내 기능 내 UIButton
행동에 노력하고 있지만,이 경우에는 뭔가 없거나 임 뭔가 잘못하고 있다면 나도 몰라, 작동하지 않는 buttons
을 가능하게하는 함수를 만들었습니다.
PS :
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()
}
어떻게 버튼을 사용/사용 중지 하시겠습니까? – Jeyamahesan
[여기에 이전 비슷한 질문의 해결책입니다] (http://stackoverflow.com/questions/39240170/how-disable-rest-of-the-buttons-from-an-array-of-buttons-when-button- - 39240503 # 39240503) – aatalyk
내 게시물이 업데이트되었습니다. 버튼을 사용하지 않도록 설정하는 방법이 있습니다. –