电话号码自动间距,就像 iPhone 上的地址簿一样
当我在电话应用程序的键盘上输入电话号码并添加联系人时,我希望能够复制通讯录应用程序和电话应用程序中地址簿的功能。
我知道我可以在每次将字符输入 UITextField 时进行检查,但是那里有数百种数字格式,我需要永远对它们进行编码。
是否有任何我可以使用的 API 或任何我可以使用的已知开源代码?
I want to be able to replicate what the AddressBook does in Contacts app and Phone app when entering a phone number in both the keypad on the Phone app and adding a contact.
I know I could do it checking each time a character is entered into the UITextField but there are hundreds of number formats out there and it would take me forever to code it all.
Is there any API to this I can use or any known open source code I could use at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UIPhoneFormats.plist 包含每个区域设置的预定义电话格式。 您需要编写代码将输入字符串替换为这些字符串掩码。 我必须做类似的事情,我分享了我在这里得到的结果: http://the-lost-beauty.blogspot.com/2010/01/locale-sensitive-phone-number.html
The UIPhoneFormats.plist contains predefined phone formats for each locale. You'll need to write code to subsitute your input string into these string masks. I had to do something similar, and I shared the results I got here: http://the-lost-beauty.blogspot.com/2010/01/locale-sensitive-phone-number.html
您一语中的——检查每次输入的字符。
You hit the nail on the head - check the characters typed each time.