English 中文(简体)
iPhone numberpad with decimal point
原标题:

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values varies. The problem is that the number pad does not contain a key for entering a decimal point.

When I lock my phone, the number pad that comes up to enter a passcode has a custom button to make an emergency call (as seen in the following screenshot):

Numberpad with custom button http://img25.imageshack.us/img25/6426/photoejg.jpg

Does anyone know how to create a number pad with a decimal point button or a custom button (like the emergency call button above)?

Thanks.

最佳回答

There s no Apple-approved way to edit the existing keyboard. If you want them to allow it, file a feature request.

That said, it just so happens that in most applications the keyboard (instance of UIKeyboard) is a separate UIWindow, and you can iterate over the windows in the application and start adding custom subviews that respond to the appropriate touch actions. Find it by iterating over [[UIApplication sharedApplication] windows] and checking to see if the description contains the string UIKeyboard. For more info on this method and some sample code, see this answer.

Another approach is to create your own custom view and build a keyboard from scratch. Be careful if you do this, though, as it requires a lot of manual work, not only in creating the keyboard and getting the touch behavior to match Apple s, but also in any control you add that would bring up the regular keyboard - you ll need to redirect things like becomeFirstResponder to show your own keyboard, rather than Apple s.

Edit: As ZaBlanc pointed out, newer versions of iOS have a way to do this with the inputView and inputAccessoryView properties. See the UIResponder class reference for details.

问题回答

set UIKeyboardType to UIKeyboardTypeDecimalPad

Available in iOS 4.1 and later.

Create a UIViewController that contains a UIView with a bunch of buttons. Now your keyboard can have whatever you want on it.





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签