1
如何为iPhone应用程序的UITextField
中的数据输入定义输入掩码,如$d,ddd.dd
?iPhone应用程序中的UITextField输入掩码?
如何为iPhone应用程序的UITextField
中的数据输入定义输入掩码,如$d,ddd.dd
?iPhone应用程序中的UITextField输入掩码?
您想要使用NSNumberFormatter
在值1234.56
和字符串@"$1,234.56"
之间来回切换。
苹果有一个非常好的Data Formatting Guide来引导您设置和使用货币格式化程序。
为了这一个的UITextField整合,你将要使用的委托方法
- 文本框:shouldChangeCharactersInRange:replacementString:
这可以让你对他们在验证和更新字符作为用户类型。有关如何实现此示例,看看这篇文章:Re-Apply currency formatting to a UITextField on a change event
可能重复的[重新应用货币格式化到UITextField在更改事件](http://stackoverflow.com/questions/2388448/re -apply-currency-formatting-to-a-uitextfield-on-a-change-event) – PengOne
po可以复制[Obj-C,iOS,我如何格式化货币国际UITextField?](http://stackoverflow.com/questions/5850089/obj-c-ios-how-do-i-format-a-的UITextField换货币国际) –