4taras4/CountryCode

Countries order

Closed this issue · 1 comments

Hey,

I have started using Country Picker and I have encountered two issues. I hope we can solve this.

  1. I am filtering countries in pickerView, so I have got Austria, Germany, Poland, Switzerland. Is there any way I can change order of these items? I guess it's preset alphabetically. I would like to begin with Germany.
  2. When I tap on a particular country in the row, I get phoneCode from the first item in that array. I mean, I have swiped on Switzerland, it gives me +41 as it should and when I tap on that Switzerland row I get phoneCode from Austria (+43). Same with others countries beside Austria which is first in that array.

Here is my code:

func countryPhoneCodePicker(_ picker: CountryPicker, didSelectCountryWithName name: String, 
     countryCode: String, phoneCode: String, flag: UIImage) {
    countryCodeButton.setTitle(phoneCode, for: .normal)
    countryImage.image = flag
}


 func initPicker() {
    let locale = Locale.current
    guard let code = (locale as NSLocale).object(forKey: NSLocale.Key.countryCode) as! String? 
   else {
        return
      }

    countryPicker.displayOnlyCountriesWithCodes = StringConstants.codes.countryCodes
    countryPicker.countryPickerDelegate = self
    countryPicker.showPhoneNumbers = true
    countryPicker.setCountry(code)
}

I'll solve it soon, thank you