当我第一次按下按钮时,标签显示"谁是Arnold?"
当我第二次按下BUTTON时,我想要"凯文是谁?"要显示在标签字段上,而不是"谁是Arnold?"
当我第三次按下按钮时,我想要"谁是刘?"要显示在标签字段上,而不是"谁是凯文?"
@IBAction func answerButtonTapped(send: UIButton){
var question = questionField.text
var i = 0
var listOfQuestions = ["Who is Arnold?", "Who is Kevin?", "Who is Liu?"]
for (i=0; i<=listOfQuestions.count; i++){
questionField.text = "(listOfQuestions[i])"
}
}
答案 0 :(得分:1)
var counter = 0
var listOfQuestions = ["Who is Arnold?", "Who is Kevin?", "Who is Liu?"]
@IBAction func answerButtonTapped(send: UIButton){
questionField.text = listOfQuestions[counter%listOfQuestions.count]
counter++
}