【发布时间】:2010-11-13 03:05:00
【问题描述】:
如何获得带小数点分隔符的数字键盘?目前我被 UIKeyboardNumberPad 卡住了。
【问题讨论】:
标签: iphone objective-c keyboard uitextfield
如何获得带小数点分隔符的数字键盘?目前我被 UIKeyboardNumberPad 卡住了。
【问题讨论】:
标签: iphone objective-c keyboard uitextfield
你可以试试这个
UIKeyboardTypeDecimalPad
【讨论】:
typedef enum {
UIKeyboardTypeDefault,
UIKeyboardTypeASCIICapable,
UIKeyboardTypeNumbersAndPunctuation,
UIKeyboardTypeURL,
UIKeyboardTypeNumberPad,
UIKeyboardTypePhonePad,
UIKeyboardTypeNamePhonePad,
UIKeyboardTypeEmailAddress,
UIKeyboardTypeDecimalPad,
UIKeyboardTypeTwitter,
UIKeyboardTypeWebSearch,
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable // Deprecated
} UIKeyboardType;
如果你不喜欢这些,你可以随时在代码中修改它们......
http://openradar.appspot.com/6635276
这有一个解决方案: http://www.iphonedevsdk.com/forum/iphone-sdk-development/6573-howto-customize-uikeyboard.html
【讨论】:
UIKeyboardTypeNumbersAndPunctuation 可能是最不坏的选择,除非您有时间和资源来滚动自己的键盘。
【讨论】:
iPhone SDK 目前不提供键盘 (0-9) + 十进制按钮 UIKeyboard。我怀疑这是设计的,因为对于大多数用例来说,它是不需要的。
参见this previous StackOverflow question 讨论货币输入是否需要小数点分隔符。我还写了一个 blog post 关于这个话题。
但是,如果您确实需要小键盘 + 十进制按钮键盘,您唯一的选择就是滚动您自己的自定义键盘。与 sbwoodside 的回答相反,您真的想回避自定义现有的 UIKeyboard。虽然这可能很容易做到,但它依赖于可以随时更改的私有类……这意味着您的 hack 将来可能会在没有警告的情况下被破坏。
【讨论】: