Adding Buttons to UIKit’s Numpad
On a current project, users need to enter their locations by latitude andlongitude. True, the real world use of such a feature is dubious (do you know, right now, your latitude and longitude to four digits? Or the lat/lng of your destination? Yes? Well, my response to you, dear reader, is STOP DRIVING while reading blogs!). However, to make a simple calculator — or even more basically, to enter a number and then Return — you will need more than the UIKit-provided numpad.
You want to make a vanilla calculator. You would like to enter numbers to a
UITextField without the default alphanumeric keypad, but rather with a number pad. However, the
UIKeyboardTypeNumberPad was “designed for PIN entry,” and just contains the digits.
Add a custom
UIToolbar on top of the default Numpad with the button(s) you require.