I was wondering how I can format the textField that I'm using for a phone number (ie like the "Add New Contact" page on the iPhone. When I enter in a new mobile phone, ex. 1236890987 it formats it as (123) 689-0987.) I already have the keyboard set as the number pad.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- back button text does not change
相关文章
- 现在使用swift开发ios应用好还是swift?
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- How do you detect key up / key down events from a
Updated answer from Vikzilla for Swift 3:
Updated answer from "iOS Unit" for Swift 3 with format +X(XXX)XXX-XXXX:
My solution for +X (XXX) XXX-XXXX format. (SWIFT)
Unfortunately, you have to do it yourself. The contact app uses undocumented APIs. For some reason attaching input formatters to text fields is not exposed on the iPhone the way it is on the Mac. Feel free to file a feature enhancement bug report.
I've been struggling with this for a couple of hours, here's what I have:
I hope someone can contribute.
Here is my solution for 05xx xxx xxxx phone format. At the beginning I set
It also covers copy/paste cases for cursor position.
Maybe it helps someone for different formats.