2 Replies
      Latest reply on May 20, 2020 4:35 AM by Armand_Mona
      Armand_Mona Level 1 Level 1 (0 points)

        The keyboard is not a problem, but will not dismiss when the app is loaded onto a real phone.

        In line 21 below we tried resignFirstResponder(), but it did not work.

        We are unsure on where to put the line to resignFirstResponder().

        Any help you can provide is appreciated.

         

            @IBOutlet weak var textField: UITextField!
            @IBOutlet weak var countryImage: UIImageView!
            @IBOutlet weak var correctionLabel: UILabel!
            @IBOutlet weak var scoreLabel: UILabel!
            
            @IBOutlet weak var countryLinks: UIButton!
            @IBAction func countryLinksPressed(_ sender: UIButton) {
               if let url = URL(string: "\(questions[questionNumber].countryLink)") {
                    UIApplication.shared.open(url, options: [:])
                }
            }
            
            var questionNumber = 0
            var score = 0
            var response = ""
            
            @IBOutlet weak var submitButton: UIButton!
            @IBAction func submitButtonPressed(_ sender: Any) {
                response = textField.text!
                //line below causes a crash
                //textField.resignFirstResponder()
                if (response.lowercased() == questions[questionNumber].correctAnswer) {
                score += 1
                scoreLabel.text = "Score: \(score)"
                correctionLabel.text = "Correct"
                correctionLabel.textColor = UIColor.green
                    }
                
            else {
                correctionLabel.text = "Incorrect"
                correctionLabel.textColor = UIColor.red
                    }
                    
             if (questionNumber + 1 == questions.count) {
                endQuiz()
                }
            }