I'm beginning to learn Xcode and as the first app i decided to write a calculator. I did everything and it works pretty good but there is one thing i couldn't find. I want when the user writes Letters instead of numbers and taps the button , an alert appear and prevents him from entering letters.I'll appreciate you if help me and sry for my bad english.
Asked
Active
Viewed 163 times
1
-
Why don't you just eliminate the possibility of the user typing numbers? Also, may want to check out http://stackoverflow.com/questions/2719680/iphone-uitextfield-only-integer – tarheel Jul 11 '12 at 15:28
2 Answers
1
If you don't want to allow the user to type letters at all you'll be much better off using the numeric keyboard. The decimal numeric keypad is available in iOS 4.1 and up, and you can find out more about it from this question:
How to use the new UIKeyboardTypeDecimalPad feature in iOS 4.1 SDK
0
As the comment said, you'll probably be better off just changing the input type of the keyboard.
[myTextField setKeyBoardType:UIKeyboardTypeDecimalPad] // has a decimal, use UIKeyboardTypeNumberPad for no decimal
See list of all available types here.

Dima
- 23,484
- 6
- 56
- 83
-
1Sorry guys i'm new and i don't know hot to vote your comments. Anyway thank u so much for solving my problem. – user1518235 Jul 11 '12 at 15:56