尽管存在该命令,UIAlertController仍未显示

时间:2017-10-20 13:56:15

标签: ios swift uialertcontroller

我正在写一个简单的测验应用程序。虽然UIViewController是在按钮操作中实现的,但它不会被触发。

@IBAction func answerPressed(_ sender: AnyObject) {
    nextQuestion()
    failingMethod()
}

func nextQuestion() {
    questionIndex+=1
    if(questionIndex >= allQuestions.list.count){
        let alert = UIAlertController(title: "Awesome", message: "You've finished all the questions, do you want to start over?", preferredStyle: .alert)

        let restartAction = UIAlertAction(title: "Restart", style: .default, handler: { UIAlertAction in
            self.startOver()
        })

        alert.addAction(restartAction)

        present(alert, animated: true, completion: nil)
    } 
}

0 个答案:

没有答案