dimanche 27 janvier 2019

Alert controller not showing

I am working on a quizz-app and I want to show an alert when a statement is true. Somehow tho it's not showing the alert controller and I dont know why.
The test-prints giving me
true
0
got in
Edit: Code running after clicking on a Button

Here is the code:

@IBAction func trainingModeButton(_ sender: Any) {
    print(useTrainingQuestionsOnly)
    print(trainingQuestions.count)
    if useTrainingQuestionsOnly == true || trainingQuestions.count == 0 {
        print("got in")
        let alertController = UIAlertController(title: "Warnung!", message: "Es befinden sich keine Fragen in den Übungsaufgaben! Um alle Fragen zu spielen, ändere deine Einstellungen!", preferredStyle: UIAlertControllerStyle.alert)
        alertController.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: nil))
        alertController.addAction(UIAlertAction(title: "Einstellungen", style: UIAlertActionStyle.default, handler: { action in self.performSegue(withIdentifier: "MainToOptions1", sender: self)}))
        self.present(alertController, animated: true, completion: nil)
    }

Aucun commentaire:

Enregistrer un commentaire