0

I am new to Swift and this is my first application. I essentially want a user to enter two numbers, that I can use for some calculations. For the text fields I used the option "Decimal Pad" as keyboard type. With the simulator it works well - on my phone, however, the dot is shown as a comma, which causes the app to crash. Is there an easy fix for this problem? I don't want any global changes for the location or the keyboards used, but just a fixed decimal pad with dot instead of comma.

Thank you!

spadel
  • 998
  • 2
  • 16
  • 40
  • Does this answer your question? [Numeric keyboard with decimal](https://stackoverflow.com/questions/35437604/numeric-keyboard-with-decimal) – AlexH Sep 04 '20 at 23:09
  • "which causes the app to crash" Then you need to work on why that is. You are concentrating on the wrong thing. You should be asking about the crash, not trying to subvert the good interface of the phone. – matt Sep 04 '20 at 23:13
  • Thanks for the comment. Unfortunately it doesn't, I am choosing the decimal pad, but on my phone (I am German) the dot is shown as a comma, which seem to break the calculation. – spadel Sep 04 '20 at 23:14
  • @matt I know exactly why it crashes: Since the decimal pad forces me to use a comma instead of a dot the input is not a valid number anymore. – spadel Sep 04 '20 at 23:16
  • That is why I say you need to ask about the crash. Clearly you are not turning the text into a number correctly. Show how you are doing it and we can help. – matt Sep 04 '20 at 23:21
  • Thank you, my code for turning text into number looks as follows `let height = Double(groesseTextField.text!)!` – spadel Sep 04 '20 at 23:22
  • @spadel https://stackoverflow.com/a/27932153/2303865 – Leo Dabus Sep 05 '20 at 00:06

0 Answers0