user1518235
user1518235

Reputation: 13

How to get textfield characters?(Xcode)

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.

Upvotes: 1

Views: 164

Answers (2)

Dima
Dima

Reputation: 23624

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.

Upvotes: 0

lxt
lxt

Reputation: 31294

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

Upvotes: 1

Related Questions