Post

Replies

Boosts

Views

Activity

Xcode 13.2.1 : alert mishandling on Iphone but working on simulator ???
Hello everyone! I'm just working on my first app in swift, and am out of knowledge about this case. First, the related code : `@IBAction func ajouterNouvelleValeur(_ sender: Any) { // Créer une alerte pour saisir la nouvelle valeur let alert = UIAlertController(title: "Ajouter une nouvelle valeur", message: nil, preferredStyle: .alert) alert.addTextField { (textField) in textField.placeholder = "Entrez la nouvelle valeur" } // Ajouter un bouton "Ajouter" pour ajouter la nouvelle valeur alert.addAction(UIAlertAction(title: "Ajouter", style: .default, handler: { [weak self] action in guard let textField = alert.textFields?.first, let newValue = textField.text else { return } self?.ajouterNouvelleValeur(newValue) })) // Ajouter un bouton "Annuler" alert.addAction(UIAlertAction(title: "Annuler", style: .cancel, handler: nil)) // Afficher l'alerte present(alert, animated: true, completion: nil) } this to present an alert with textField to enter a new value to an array. Works properly on simulator, but when testing on my iPhone12 SE, it appears not to catch any value for the textField. Has anyone encountered the same issue, and knows the solution? Hope my english is not too bad (as a French member, I appologize if not!) Best regards Sébastien
1
0
533
Feb ’24