chronotruck / flagphonenumber Goto Github PK
View Code? Open in Web Editor NEWA formatted phone number UITextField with country flag picker.
License: Apache License 2.0
A formatted phone number UITextField with country flag picker.
License: Apache License 2.0
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Setting view controller and then popping that view controller makes retain cycle, and both of them don't get deallocated.
Temporary fix is to not set parentViewController.
Hi @grifas ! Love this project!
In my current app, I'd like to freeze the flag to the US one.
I took a look at the code (PhoneNumberTextField.swift) and figured out that the flag button's user interaction needs to be disabled for this task.
So basically, I'll have to change
private var flagButton: UIButton!
to
public var flagButton: UIButton!
or
create a method to update the button's characteristics.
Which approach do you recommend, and is it alright if I submit a PR with this enhancement?
I want to create CTKFlagPhoneNumberFields in storyboard itself.
Now its throwing error while setting textfield in storyBoard.
By default I have American flag set, but when I change phone to my Belarussian phone with set(phoneNumber: String)
, flag doesn't changes (though phone changes properly and code accepted fine):
Fortunately, it is easy to fix - seems like all one need to do is to add setFlag(with: phoneUtil.getRegionCode(for: parsedPhoneNumber))
to CTKFlagPhoneNumberTextField.swift around 142 line. If required, I can make a fork and submit possible fixes via pull requests.
Describe the bug
Delegate method is not getting called, Insert ' as! UITextFieldDelegate'
To Reproduce
class ViewController: UIViewController, FPNTextFieldDelegate {
In viewDidLoad
phoneNumberTextField.delegate = self
Expected behavior
The delegate should be set and methods may get called.
Screenshots
If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
FlagPhoneNumber (please complete the following information):
Additional context
N/A
For Netherlands (+31) the functions getFormattedPhoneNumber() and getRawPhoneNumber() return nil
Is there any reason to not do something like this:?
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
Right now due to current implementation it is impossible to create CTKFlagPhoneNumberTextField in .xib file or storyboard. If there are no reasons to disallow creation from xibs it would be awesome to implement initWithCoder.
Library compiling and working with Swift 4.2 and Xcode 10
It doesn't compile with 4.2
While we set number to CTKFlagPhoneNumberTextField it was reflecting with proper country flag
After your last committed changes number is not getting set to textfield.
I have installed pods, changed Class of UITextfield to CTKFlagPhoneNumberTextField
and just used your given method
phoneNumberTextField.set(phoneNumber: "some number with country code")
This was working fine before your last commit, now I am facing problems
what happens is textfield gets set to empty and and when I try to set it manually I am not able to see flags of desired countries?
This issue I was facing on pod version (0.4.6)
can you customise in the table view
@maffpool I ran the newest pod and when I run getphonenumber it just gives me the phone number set in viewdidload, it doesn't give me the actual phone number in the textfield. Can you fix this issue. Run pod install again on this project, then press ok button when you enter invalid phone and you will see my point.
I'd like to change the color of the country code, and also the font family and font size.
Maybe by default it can take the text color and font properties that you set to the UITextField.
Thanks!
Hi,
I'm running into flags no load issue - the same as described in
When first time, app is launched, it loads Flags bundle and shows all the flags. But when I logout, and then open country picker, it doesn't show any flag. It's exactly same issue as commented on above links.
Did you find any solution to this problem. I tried latest code, but the issue seems to persist there too.
Thanks,
Abdul
When I touch the flag, the flag picker appears and it has an accessory view with a "Done" button. But when I touch the textField, the keypad doesn't have an accessory view. And I can't also add a custom accessory view made by me.
when touch country text field at any place i expected to got countrypicker opened directly ,but i found that text field can be editing and i want to stop text field editing and make action not on flag only on text and flag image
Just like Android setPhoneNumberValidityChangeListener, there should be a callback or delegate method
There is no way to validate entered phone number
Simple to enter any phone number but you will not notify on your ViewController
I am using one which you suggested into Github
Request is very clear.I think, it should support for all countries.
Describe the bug
Number keyboard pad lost after country selection when used in tableview (static)
To Reproduce
Steps to reproduce the behavior:
use it in a tableview (static)
change country
keyboard type is not the number pad
Expected behavior
Keyboard type should stay in the number pad
Smartphone (please complete the following information):
FlagPhoneNumber (please complete the following information):
Do not want to show flag how can I do that?
I want to show only number with Country.
Hi There,
I have integrated "CTKFlagPhoneNumber" in my project
phoneNumberTextField.set(phoneNumber: "0600000001")
is not working in my case. I am not getting pre populated number and flag and In some cases it gets crashed.
I have Integrated it a day before and it was working fine, I think this issues are due to latest update , could please help me on same.
Thanks in Advance
Describe the bug
Flag is not visible on iPad - both landscape and portrait mode
To Reproduce
Steps to reproduce the behavior:
Expected behavior
App should show the flag as it does on iPhone
Smartphone:
FlagPhoneNumber :
Additional context
Issue only on iPad, working fine on iPhone.
i have added a textfield(FPNTextField) in a stack view through interface builder
then when i try to select from the ui my specific country it makes cursor invisible and keyboard becomes default for number-pad
I'm not sure if I'm overlooking something, but I can't seem to find a way to retrieve the country code. I tried extending the CTKFlagPhoneNumberTextField class and overriding the country picker delegate but I can't, since its not marked "open".
Please advise, thank you.
I am using this framework,
But, it's not support some methods.
print(phoneNumberTextField.getFormattedPhoneNumber())
print(phoneNumberTextField.getCountryPhoneCode())
print(phoneNumberTextField.getRawPhoneNumber())
I also cannot insert the search button like you.
How to fix it?
Please help me!
Thanks and Regard.
Can't type / select flag with latest pod. Reverted to 'improvement-2' branch and renaming classes to old convention removed the issue.
Hi @grifas
I'm running into flags no load issue - the same as described in
When first time, app is launched, it loads Flags bundle and shows all the flags. But when I logout, and then open country picker, it doesn't show any flag. It's exactly same issue as commented on above links.
Did you find any solution to this problem. I tried latest code, but the issue seems to persist there too.
Thanks,
Abdul
Is your feature request related to a problem? Please describe.
Hello! A nice improvement would be the ability to tap the country code to bring up the country code picker. Currently, only tapping the flag brings up the country picker.
Describe the solution you'd like
Tapping the country code e.g. "+00" will bring up the country picker to allow selecting another country.
Describe alternatives you've considered
I tried to make another invisible button centred on the country code to get it to trigger the country picker, but I couldn't get it working.
Additional context
I was trying to hide flags while still allowing the changing of the country codes but I couldn't quite create a fix. Thanks for making this library, it's really useful.
Hi,
I am not able to set the textfield in storyboard, it crashes when we set it via storyboard(not programatically). Could you please suggest any solutions for the error?
I want to format the phone number. but I haven't seen an option.If you will add this feature.it will be better.
Hi,
Could you please help, how to get current Country Phone Code?
I am trying something like:
number.getCountryPhoneCode()
But get error:
Value of type 'FPNTextField?' has no member 'getCountryPhoneCode'
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
FlagPhoneNumber (please complete the following information):
Additional context
Add any other context about the problem here.
I have my TextField in Storyboard. I changed the class name CTKFlagPhoneNumberTextField and module as CTKFlagPhoneNumber. Now while validating the number getPhoneNumber() is returning me nil but when I am printing text I can see the country code and number I entered. Is there any property I need to set. Need help. Thanks in advance.
HI,
thanks for the awesome library. Just wanted to know if there is any way to get the name of the country.
For eg. if I want to get the country code, I will select the particular country from the list. But if I want the country name of the selected country code , how can I get it?
Thanks in advcance
Currently we are only able to get complete number through:
print(phoneNumberTextField.getPhoneNumber())
// Output: +33600000001
Sometime country code and raw phone number is required rather than complete number, There must be 2 more methods.
print(phoneNumberTextField.getCountryCode())
// Output: +33
print(phoneNumberTextField.getRawPhoneNumber())
600000001
Hi There,
First of all thank you for your great library. :)
I am implementing Country code picker into one of my app but i have one concern that i dont want to implement phone number formatting. But in your code formatting is by default. So is there any way to disable it?
Thank You!!
Are there any plans to support phone numbers with extensions? For example, 613-555-0415, Ext. 126 . This would be a nice feature to have.
I have readed README.md
I had set phoneNumberTextField.parentViewController = self
But, the Search button not show in the picker.
how to fix it ?
The project is cool, thanks! Is there any plan to support Carthage?
Thanks
Hi @grifas , the US phone code (+1) is deletable.
It seems that something is wrong with the UITextField delegate and the way it processes the input.
Describe the bug
Flag is not visible on iPad - both landscape and portrait mode
To Reproduce
Steps to reproduce the behavior:
Expected behavior
App should show the flag as it does on iPhone
Smartphone:
FlagPhoneNumber :
Additional context
Issue only on iPad, working fine on iPhone.
when i have add CTKFlagPhoneNumber text field in scroll scroll then i am unable to edit it. its always show me country picker and m unable to enter phone number . but when i add it outside main view then it works perfect
Hi @grifas .
It would be really great if the library allows the developer to restrict the flags & formats shown in the CTKFlagPhoneNumberTextField.
Some apps are only released in certain countries, hence it makes sense to restrict the phone numbers allowed to be entered into the text field.
App crash due to this function, mostly first time when its loads.
func setCountryByRow(row: Int) {
self.selectRow(row, inComponent: 0, animated: true)
let country = countries[row]
if let countryPickerDelegate = countryPickerDelegate {
countryPickerDelegate.countryPhoneCodePicker(self, didSelectCountryWithName: country.name!, countryCode: country.code!, phoneCode: country.phoneCode!, flag: country.flag!)
}
}
We've gotten a few crashes in related to the following line:
Locale.current.regionCode
is an optional return - so it may return nil, which will crash as the code is adding a !
I'm not sure if the country picker supports having an empty country or not.
Please take a look:
Crashed: com.apple.main-thread
0 CTKFlagPhoneNumber 0x100b34b64 _T018CTKFlagPhoneNumber15MRCountryPickerC15setCountryByRowySi3row_tF + 948
1 CTKFlagPhoneNumber 0x100b314fc _T018CTKFlagPhoneNumber0abC9TextFieldC5setup33_D5149F41D855A9C52E54B091304B013ELLyyF + 1148
2 CTKFlagPhoneNumber 0x100b32d4c _T018CTKFlagPhoneNumber0abC9TextFieldCACSgSo7NSCoderC5coder_tcfcTf4gn_n + 248
3 CTKFlagPhoneNumber 0x100b30fb0 _T018CTKFlagPhoneNumber0abC9TextFieldCACSgSo7NSCoderC5coder_tcfcTo + 36
4 UIKit 0x18962ecb8 -[UIClassSwapper initWithCoder:] + 248
5 UIKit 0x189743bf0 UINibDecoderDecodeObjectForValue + 672
6 UIKit 0x189743d68 UINibDecoderDecodeObjectForValue + 1048
7 UIKit 0x189743938 -[UINibDecoder decodeObjectForKey:] + 336
8 UIKit 0x18947bfb4 -[UIView initWithCoder:] + 608
9 UIKit 0x189743bf0 UINibDecoderDecodeObjectForValue + 672
10 UIKit 0x189743938 -[UINibDecoder decodeObjectForKey:] + 336
11 UIKit 0x18962e95c -[UIRuntimeConnection initWithCoder:] + 188
12 UIKit 0x189743bf0 UINibDecoderDecodeObjectForValue + 672
13 UIKit 0x189743d68 UINibDecoderDecodeObjectForValue + 1048
14 UIKit 0x189743938 -[UINibDecoder decodeObjectForKey:] + 336
15 UIKit 0x18962dc90 -[UINib instantiateWithOwner:options:] + 1220
16 UIKit 0x1894e6cfc -[UIViewController _loadViewFromNibNamed:bundle:] + 376
17 UIKit 0x1892bbea8 -[UIViewController loadView] + 176
18 UIKit 0x189183258 -[UIViewController loadViewIfRequired] + 144
19 UIKit 0x1891831b0 -[UIViewController view] + 28
20 UIKit 0x1894f5c18 -[UIViewController _setPresentationController:] + 108
21 UIKit 0x1894eee74 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1328
22 UIKit 0x1894f085c -[UIViewController _presentViewController:withAnimationController:completion:] + 4428
23 UIKit 0x1894f3294 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 472
24 UIKit 0x18927a0c0 -[UIViewController presentViewController:animated:completion:] + 184
25 PrintOSMobile 0x1000a2894 +[Navigator presentPhoneNumberViewControllerOnAViewController:andDelegate:] (Navigator.m:625)
26 PrintOSMobile 0x1000b3cd8 -[SetPhoneNumberPopupBuilder presentDialog:withCompletionBlock:] (SetPhoneNumberPopupBuilder.m:68)
27 PrintOSMobile 0x10006d42c __47-[PopupsManager shouldShowSetPhoneNumberPopup:]_block_invoke (PopupsManager.m:297)
28 PrintOSMobileLibCore 0x1012e45a4 -[ResponseSerializer executeBlock:withResult:] + 48
29 PrintOSMobileLibCore 0x1012e4190 __60-[ResponseSerializer parseJSON:resultClass:success:failure:]_block_invoke + 84
30 libdispatch.dylib 0x1999017b0 _dispatch_call_block_and_release + 24
31 libdispatch.dylib 0x199901770 _dispatch_client_callout + 16
32 libdispatch.dylib 0x199906e20 _dispatch_main_queue_callback_4CF + 1844
33 CoreFoundation 0x183be4258 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12
34 CoreFoundation 0x183be20c0 __CFRunLoopRun + 1628
35 CoreFoundation 0x183b10dc0 CFRunLoopRunSpecific + 384
36 GraphicsServices 0x18efac088 GSEventRunModal + 180
37 UIKit 0x1891eaf60 UIApplicationMain + 204
38 PrintOSMobile 0x10013c12c main (main.m:14)
39 libdyld.dylib 0x1999328b8 start + 4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.