kizitonwose / countrypickerview Goto Github PK
View Code? Open in Web Editor NEWA simple, customizable view for efficiently collecting country information in iOS apps.
License: MIT License
A simple, customizable view for efficiently collecting country information in iOS apps.
License: MIT License
How to set particular country name flag and code.
Hello
Please change the name of Iran country from "Iran, Islamic Republic of Persian Gulf" to "Islamic Republic of Iran" in CountryCodes.json file.
Of course "Iran" itself can be used
Hey 👋 first of all thank you for this library! I'm using the latest version on iOS 12.1 and the problem with searchbar still occurs (I saw that it was already closed here #13). Can you fix it? :)
In my app every viewController is present modally, But my countryList view controller is pushed from left on Login screen, I don't know why ? I had also tried passing nil to hostViewController in viewWillAppear and vice versa, but doesn't work.
In my other two classes Registration and Update profile countryList is present modally perfectly.
Please see the attached image of my storyboard.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modal view controller on itself. Presenting controller is <UISearchController: 0x7ffccd57b340>.'
//my code
var CountryPickerCode = CountryPickerView()
override func viewDidLoad() {
super.viewDidLoad()
CountryPickerCode = CountryPickerView(frame: CGRect(x: 0, y: 0, width: txtCode.frame.size.width-10, height: txtCode.frame.size.height-10))
CountryPickerCode.delegate=self
txtCode.leftView = CountryPickerCode
txtCode.leftViewMode = .always
}
func countryPickerView(_ countryPickerView: CountryPickerView, didSelectCountry country: Country) {
self.CountryCode=country.phoneCode
txtCode.leftView=CountryPickerCode
txtCode.leftViewMode = .always
}
Add country code in the picker list with searchable support?
Thanks for the great project.
Hello, when will bitcode be enabled for countryPickerview? This makes our project enable to archive. Can you fix it soon?
ld: bitcode bundle could not be generated because '/...-hkkklqumysmrlnaulunyqgxvswbc/Build/Products/Release-iphoneos/CountryPickerView/CountryPickerView.framework/CountryPickerView' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build file '/..-hkkklqumysmrlnaulunyqgxvswbc/Build/Products/Release-iphoneos/CountryPickerView/CountryPickerView.framework/CountryPickerView' hkkklqumysmrlnaulunyqgxvswbc/Build/Products/Release-iphoneos/CountryPickerView/CountryPickerView.framework/CountryPickerView' for architecture arm64
How can I change searchStyle of searchBar?
I've tried viewController.searchController?.searchBar.searchBarStyle = .minimal
in delegate's didShow
method, but in this case user will see transition from old to new style. willShow
is too early, searchController is not initializated.
Steps to reproduce
Actual behavior
The CountryPickerViewController is pushed (because of the navigation controller), but there is no navigation bar with back button (see attached screenshot).
Expected behavior
The CountryPickerViewController has navigation bar with back or close button.
Additional context
Currently I can't find an easy way to present a picker controller if UINavigationController is a top view controller. This can be done by calling showCountryList
method, but this method is called automatically if you tap on the text field left view.
It would be better to have an optional parentViewController
property in the CountryPickerView class, that will allow you to specify which controller should present the CountryPickerViewController. If the property is nil, execute the current solution.
I need to internationalize the Country name, but I can't create new Countries because the constructor is internal.
Why scrolling is lagging? I am getting these outputs in console and scroll lags noticeably. Is this alright and nothing can be done?
[UIWorkIntervalTiming] workIntervalStart: startTimestamp > targetTimestamp; rolling forward by 0.066730
2019-07-21 21:35:28.575370+0300 testing[629:19916] [UIWorkIntervalTiming] workIntervalStart: startTimestamp > targetTimestamp; rolling forward by 0.049998
2019-07-21 21:35:32.110095+0300 testing[629:19916] [UIWorkIntervalTiming] workIntervalStart: startTimestamp > targetTimestamp; rolling forward by 0.299243
2019-07-21 21:35:33.497742+0300 testing[629:19916] [UIWorkIntervalTiming] workIntervalStart: startTimestamp > targetTimestamp; rolling forward by 0.199321
2019-07-21 21:35:34.913068+0300 testing[629:19916] [UIWorkIntervalTiming] workIntervalStart: startTimestamp > targetTimestamp;
How can I change leftBarButtonItem
's color?
Library does not support swift 5 and it is a problem. Possible estimates?
Edit. Closing, will fork and compile in swift 5.0
i have a UINavigationController that presents A ModalViewController , the ModalViewController contains the CountryPickerView, so when the CountryPickerView is tapped, the CountryPickerViewController is pushed behind the ModalViewController and not Presented , this how the Library is built and can be easily Fixed, by adding a choice of Present or push
public func showCountriesList(from viewController: UIViewController) {
let countryVc = CountryPickerViewController(style: .grouped)
countryVc.countryPickerView = self
if let viewController = viewController as? UINavigationController {
delegate?.countryPickerView(self, willShow: countryVc)
viewController.pushViewController(countryVc, animated: true) {
self.delegate?.countryPickerView(self, didShow: countryVc)
}
} else {
let navigationVC = UINavigationController(rootViewController: countryVc)
delegate?.countryPickerView(self, willShow: countryVc)
viewController.present(navigationVC, animated: true) {
self.delegate?.countryPickerView(self, didShow: countryVc)
}
}
}
i can present it Manually Ofc and it works since the ModalViewController is not part of the UINavigationController , but i can't override the tapGesture thats provided by the View.
any help would be Wonderful
I found this when I tried it in a UITextField with dark background.
Also we can give user the support to change the Font.
I created a pull request adding these feature
Application tried to present modal view controller on itself. Presenting controller is <UISearchController: 0x7ff30a247c40>.'
after select country, the font setting return to default.
Hello
The textview doesnt show the countrycode
How can i print the countrycode ?
How can I change locale with selection? User can select different languages in our app and we override strings. How can I also override default locale in countryPickerView? If that is impossible, how can I access strings of countryPickerView and set them myself? I need to change text of Back, search and Cancel
I press customCountry button which launches country list. For some strange issue I can see one country as already being checked... In some devices this country is in the middle of the list, and on some it is the first country.
Also if I remove countries from list or add some, it also affects country List and makes a single country checked. I would like to know why some countries become selected even without pressing them? It is definitively a bug which really creates problems for our use case... I would like to contribute for fixing this version.
Hi @kizitonwose
Thanks for the awesome library.
Is there any way where I can disable some countries?
How to show Full country Name.
Country phone Code Hiding is not working.
Even if I change the locale into Arabic, this picker view is showing only English Country name.
Hi, I'm using Xcode 9.2 and Swift 4
When I'm trying to implement delegate method didSelectCountry, I get the error:
Type 'MBRegisterTableViewController' does not conform to protocol 'CountryPickerViewDelegate'
but I already have
func countryPickerView(_ countryPickerView: CountryPickerView, didSelectCountry country: Country) {}
Navigation bar changes color after tap on search field and tap Cancel. after that if return to parent view, navigationBar color changed and there. After second time, in the bottom of navigationBar appears black line.
I am trying to initialise country picker view as suggested in the demo.
let countryPicker = CountryPickerView()
But the compiler asks for the Missing argument for parameter 'countryCodes' in call.
I am able to run the demo project successfully. But not able to use it in my project.
Any help will be appreciated.
error;
019-02-15 15:50:52.666326+0300 "[15045:5380788] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/containers/Bundle/Application/8952FEB6-1515-4844-B9AF-18975BCBF6C3/xxx.app/Frameworks/CountryPickerView.framework/CountryPickerView.bundle> (not yet loaded)' with name 'CountryPickerView''
@kizitonwose
Can you try carthage?
Version - 2.2.5
Installed through CocoaPods -
pod 'CountryPickerView', '~> 2.2.5'
Circle ci builds started to fail after updating to 2.2.5, local builds are fine, only when the archive is made on ci server the following error occurs, any advice or direction is much appreciated!
Stack trace -
[06:43:20]: ▸ Copying CountryPickerView-umbrella.h
[06:43:20]: ▸ Compiling CountryPickerView.swift
[06:43:20]: ▸ Compiling CountryPickerViewController.swift
[06:43:20]: ▸ ❌ /Users/distiller/project/Pods/CountryPickerView/CountryPickerView/CountryPickerViewController.swift:231:18: method 'searchBarTextDidBeginEditing' must be declared public because it matches a requirement in public protocol 'UISearchBarDelegate'
[06:43:20]: ▸ private func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
[06:43:20]: ▸ ~~~~~~~ ^
[06:43:20]: ▸ ❌ /Users/distiller/project/Pods/CountryPickerView/CountryPickerView/CountryPickerViewController.swift:237:18: method 'searchBarCancelButtonClicked' must be declared public because it matches a requirement in public protocol 'UISearchBarDelegate'
[06:43:20]: ▸ private func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
[06:43:20]: ▸ ~~~~~~~ ^
[06:43:20]: ▸ ❌ /Users/distiller/project/Pods/CountryPickerView/CountryPickerView/CountryPickerViewController.swift:248:18: method 'willPresentSearchController' must be declared public because it matches a requirement in public protocol 'UISearchControllerDelegate'
[06:43:20]: ▸ private func willPresentSearchController(_ searchController: UISearchController) {
[06:43:20]: ▸ ~~~~~~~ ^
[06:43:20]: ▸ ❌ /Users/distiller/project/Pods/CountryPickerView/CountryPickerView/CountryPickerViewController.swift:252:18: method 'willDismissSearchController' must be declared public because it matches a requirement in public protocol 'UISearchControllerDelegate'
[06:43:20]: ▸ private func willDismissSearchController(_ searchController: UISearchController) {
[06:43:20]: ▸ ~~~~~~~ ^
[06:43:20]: ▸ Compiling Delegate+DataSource.swift
[06:43:20]: ▸ Compiling Extensions.swift
[06:43:20]: ▸ Compiling NibView.swift
[06:43:20]: ▸ ** ARCHIVE FAILED **
[06:43:20]: ▸ The following build commands failed:
[06:43:20]: ▸ CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
[06:43:20]: ▸ CompileSwift normal arm64 /Users/distiller/project/Pods/CountryPickerView/CountryPickerView/CountryPickerViewController.swift
[06:43:20]: ▸ (2 failures)
Hello...
Came across your very nice project and as logo designer who loves to contribute to open source projects, I want to help contribute by creating a unique logo for your project which will give it its own identity.
Working on some cool logo design ideas currently... I will post the idea concepts here once i complete it, so you can give me your feedback to make any changes or tweak to suit your needs.
it is not in the same line with textField @kizitonwose
The podspec is malformed, you cannot use it in other platforms like cordova. here is information:
https://stackoverflow.com/questions/50124893/this-target-might-include-its-own-product-for-nib-in-dependency
CocoaPods/CocoaPods#7704
How soon can I expect a fix?
The flag of Iraq is still the old one. Please update the image of the Iraq flag.
I tried to install but have getting " [!] Unable to find a specification for CountryPickerView
" this error. Also added CountryPickerView.Framework but getting crash. Im using Xcode 8.3.2.
Thanks in advance.
Hi,
as far as I see Jamaica has "+876" code not "+1876"
import UIKit
import CountryPickerView
class LoginController: UIViewController{
@IBOutlet weak var phoneNumber: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
phoneNumber.setBottomBorder(backGroundColor: .white, borderColor: GREEN_THEME)
let cpv = CountryPickerView(frame: CGRect(x: 0, y: 0, width: 120, height: 20))
phoneNumber.leftView = cpv
phoneNumber.leftViewMode = .always
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func loginAction(_ sender: Any) {
print("\(phoneNumber.text)")
}
}
`
Hi
Is there a way to use this lib in an objective C project ?
Thanks for any input.
Can we able to get only Country flag through CountryPickerViewDelegate ?
What is this library size for?
Does it all include county.jpg locally?
In CountryCodes.json, South korea data is now like this.
{
"name": "Korea, Republic of South Korea",
"dial_code": "+82",
"code": "KR"
}
But, South Korea's official name is "Republic of Korea", or "Korea, Republic of Korea".
How can I change margin of country label and flag inside UIView which is used as CountryPickerView? Right now flag does not have any margin to the parent view..
Could you please add text field masking with each country's phone number pattern.
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.