GithubHelp home page GithubHelp logo

nikkovios / nkvphonepicker Goto Github PK

View Code? Open in Web Editor NEW
144.0 144.0 45.0 6.93 MB

An UITextField subclass to simplify country code's picking. Swift 5.0

Home Page: https://cocoapods.org/pods/NKVPhonePicker

License: MIT License

Swift 97.39% Ruby 1.72% Objective-C 0.89%
country country-codes example ios ios-swift nikkovios phone picker swift

nkvphonepicker's People

Contributors

artemy-ant avatar behzadardehei avatar legoless avatar libern avatar nikkovios avatar roleksandr avatar saroar avatar vineetkg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nkvphonepicker's Issues

Min and Max Phone number format

It is possible to have a minimum and maximum phone number format for each country? or for all countries?

For example:
{
"name": "Bahrain",
"dial_code": "973",
"code": "BH",
"min_format": "### ######",
"max_format": "### ########"
}

This would be useful, as many countries have multi format.

Can you help me ?

@IBOutlet public weak var phonePickerDelegate: UIViewController?

你好
请问这个phonePickerDelegate如何创建?

how are you
How to create this phonePickerDelegate ?

Keeping getting crash in NKVPhonePickerPresenter class on textField.flagView.setFlag(with: source)

General Information

In viewDidLoad when I try to insatiate the NKVPhonePickerTextField with a country it keeps crashing when trying to create the flagView in the NKVPhonePickerPresenter class' textField.flagView.setFlag(with: source).

Why does this keep happening?

    let phoneTextField: NKVPhonePickerTextField = {
        let textField = NKVPhonePickerTextField()
        textField.autocorrectionType = .no
        textField.keyboardType = .numberPad
        return textField
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        phoneTextField.phonePickerDelegate = self

        if let countryCode = Country.currentCountry?.countryCode, let country = Country.country(for: NKVSource(countryCode: countryCode)) {
            
            let source = NKVSource(country: country)
            
            phoneTextField.flagView.setFlag(with: source)
            phoneTextField.setFlag(source: source)
            phoneTextField.setFlag(source: source)
            
            phoneTextField.country = country
        }
    }

crashes in this class

class NKVPhonePickerPresenter {

    /// Method for set flag with countryCode.
    public func setFlag(source: NKVSource) {
        textField.flagView.setFlag(with: source) // ***IT CRASHES ON THIS LINE***
    }
}
  • NKVPhonePicker Version:
    2.0.3
  • iOS Version(s):
    Xcode 10.1
  • Swift Version:
    4.2
  • Device or Simulator:
    Device
  • Did you check an example:
    Yes

What happened?

What did you expect to happen?

NKVPhonePickerTextField.swift twice in project

General Information

  • NKVPhonePicker Version:
    2.0.1

What happened?

CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
cd /Users/vsts/agent/2.140.2/work/1/s/Pods
export DEVELOPER_DIR=/Applications/Xcode_9.4.1.app/Contents/Developer
export PATH="/Applications/Xcode_9.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode_9.4.1.app/Contents/Developer/usr/bin:/Library/Frameworks/Mono.framework/Versions/4/bin:/usr/local/bin:/usr/local/sbin:/Users/vsts/bin:/Users/vsts/.yarn/bin:/usr/local/go/bin:/Users/vsts/Library/Android/sdk/tools:/Users/vsts/Library/Android/sdk/platform-tools:/Users/vsts/Library/Android/sdk/ndk-bundle:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/bin:/bin:/usr/sbin:/sbin:/Users/vsts/.azcopy"
export SDKROOT=/Applications/Xcode_9.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk
>/Applications/Xcode_9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name NKVPhonePicker -O -whole-module-optimization -D COCOAPODS -suppress-warnings -sdk /Applications/Xcode_9.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk -target armv7-apple-ios9.0 -g -module-cache-path /Users/vsts/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -Xfrontend -serialize-debugging-options -embed-bitcode -swift-version 3 -I /Users/vsts/Library/Developer/Xcode/DerivedData/Robomed-hkguzfozedxpeactgxnakujerabq/Build/Intermediates.noindex/ArchiveIntermediates/Robomed/BuildProductsPath/Release-iphoneos/NKVPhonePicker -F /Users/vsts/Library/Developer/Xcode/DerivedData/Robomed-hkguzfozedxpeactgxnakujerabq/Build/Intermediates.noindex/ArchiveIntermediates/Robomed/BuildProductsPath/Release-iphoneos/NKVPhonePicker -c -num-threads 4 /Users/vsts/agent/2.140.2/work/1/s/Pods/NKVPhonePicker/Sources/Main/CountriesViewController.swift /Users/v...
:0: error: filename "NKVPhonePickerTextField.swift" used twice:
'/Users/vsts/agent/2.140.2/work/1/s/Pods/NKVPhonePicker/Sources/Main/NKVPhonePickerTextField.swift' and
'/Users/vsts/agent/2.140.2/work/1/s/Pods/NKVPhonePicker/Sources/Views/NKVPhonePickerTextField.swift'
:0: note: filenames are used to distinguish private declarations with the same name
Command /Applications/Xcode_9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

there double files NKVPhonePickerTextField in project.

'/Users/vsts/agent/2.140.2/work/1/s/Pods/NKVPhonePicker/Sources/Main/NKVPhonePickerTextField.swift'
'/Users/vsts/agent/2.140.2/work/1/s/Pods/NKVPhonePicker/Sources/Views/NKVPhonePickerTextField.swift'

What did you expect to happen?

Brazilian format is wrong

We have 2 patterns:

+55 (XX) XXXXX-XXXX
and
+55 (XX) XXXX-XXXX

country code
state code (2 digits)
4 or 5 digits, then 4 digits

It depends on which state the number is

getting dial code from phone number

Is it possible to get the dial code from the phone number?

The following code will give me the phone number along with the dial code:
txtPhoneNumber.phoneNumber

Is there any way to get the phone number without dial code, and get dial code without phone number?

Country object doesn't get updated when changing code from text field.

When I start the app, I set the default country for the NKVPhonePickerTextField using the Locale.regionCode, to display the equivalent code and flag.

If the user changes the default set country by deleting the default code and replacing it with another code, the country object associated with the NKVPhonePickerTextField doesn't get updated and when navigating to the countries view controller, the old country (the default one) is still set by a checkmark.

Wrong Flags

Hello, there's a problem with the country selection. If i select United States, it shows me the Canada Flag. The selection for UK also shows wrong flag.

Same country codes change conuntry flag

General Information

  • NKVPhonePicker Version:

  • iOS Version(s):

  • Swift Version:

  • Device or Simulator:

  • Did you check an example:

What happened?

What did you expect to happen?

Country Code

Hello, is it possible to get selected Country Code like "RU", "GB", etc?

I tried to make an extension and return
return self.flagView.currentPresentingCountry.countryCode

but im getting error 'flagview is inaccessible due to internal protection level'

Thanks

No working on ios 11

App stucks on launch screen without errors.
It is working progrmatically but not with storyboard

Pod files are not updated

Hello, first of all thank you for such an awesome library.

Just installed it via cocoapods as instructed in your README.md file. Unfortunately when implementing it, the countries view controller doesn't get presented. When comparing files downloaded via cocoapods with the files included in the provided example, they're not the same.

Thanks!

How can append text programmatically?

General Information

  • NKVPhonePicker Version:
    Last version
  • iOS Version(s):
    11.3.1
  • Swift Version:
    4.1
  • Device or Simulator:
    Device
  • Did you check an example:
    Yes,

What happened?

I am developing a softphone, I have my own numpad. I could not set pressed button value to NKVPhonePickerTextField . It's appending first digit only.

 func buttonPressed(digit: String) {   
    var val = txtDialedNumber.text
    val?.append(digit)
    txtDialedNumber.text = val

    // i tried this -> txtDialedNumber.text.append(digit)
 }

What did you expect to happen?

Force countrycode

General Information

  • NKVPhonePicker Version:
    1.2.1
  • iOS Version(s):
    11
  • Swift Version:
    4
  • Device or Simulator:
    Device
  • Did you check an example:
    yes

What happened?

there is know way to force country Not to change
by click on the flag or remove the code text

What did you expect to happen?

when delete old mobile it may not delete country code and not change the country flag

RLT Support ?

General Information

  • NKVPhonePicker Version:

  • iOS Version(s):

  • Swift Version:

  • Device or Simulator:

  • Did you check an example:

What happened?

What did you expect to happen?

wrong phone formatting

Hi!

If I set customPhoneFormats as "### ## ### ## ##" and start typing phone number, the resulting phone number looks as follows "+374 28123456678901", but when I delete digits up to country code "+374" and try to type phone number again - format applies correctly.

SPM - Crash when presenting CountriesViewController

General Information

  • NKVPhonePicker Version: 2.1.1

  • iOS Version(s): iOS 15.5

  • Swift Version: 5.5

  • Device or Simulator: Both

  • Did you check an example:

What happened?

  1. Upgrading to 2.1.1 from 2.10 using SPM. 2.
  2. Country flag is not set and textfield presents a question mark
  3. Tapping on flag button causes a crash

Could not find a storyboard named 'CountriesViewController' in bundle NSBundle

What did you expect to happen?

Tapping on flag icon should not crash.

Provide a way to disable the phone formatting calls within the library; formatting functions are broken

General Information

  • NKVPhonePicker Version:2.1.0

  • iOS Version(s):14.0

  • Swift Version:5.3

  • Device or Simulator:both and no all models

  • Did you check an example: yes

What happened?

Let's say you set (either on device or simulator) the flag for chile (using the figer taps, not programatically) and then you type in your number. It's perfect. Now let's say you go back and return to this screen, only this time the request provides you a phone number so you call the preFillText function which calls the setcode, set flag functions and sets the text property. Within both the setflag and setcode functions there are calls for formatting the phone number in accordance to your custom formats (which is not the case here) or to the current country based on the nkv source you pass in using the country code. The sources, the country codes, numbers and all of them are correct but upon "formatting" the number the phone number gets changed and is being added the last 3 chars again in the end of the number. So if the phone number is this (for chile for example): 56 9 2522 5421 then the prefilltext function will mess up with this number and in the end you will see displayed in the phone field this: 56 9 2522 5421421.
I managed to overcome this by setting the current country initially to false, setting the text property of the field as is from the response and by manually setting the phonePicker.flagView.flagButton.setImage using the UIImage constructor with the bundle. What would be nice is if we could get acces to the NKVSourcesHelper struct so we can use the static functions from there but i got the job done.

What did you expect to happen?

I expected the phone number to not get any other chars added to it, cause that's not ok at all.

Please provide a boolean so we can set it to false and if that's false then by calling preFillText it won't call the enablePhoneFormat within it and also it won't call the by callin the setFlag function it won't call the textField.presenter.enablePhoneFormat function within it.
Please provide access so we can at least call the NKVSourcesHelper struct and just get the flag(for: source) result.

Selected search Country did not reflect. Search Dismiss crashed

General Information

  • NKVPhonePicker Version: 2.0.1

  • iOS Version(s): 11

  • Swift Version: 4.1

  • Device or Simulator: Simulator

  • Did you check an example:

What happened?

Try to search country from search text field
Select country
Selected search Country did not reflect.

also, App crash when Dismiss Search

What did you expect to happen?

Selected search country should appear in the text field
The app should not crash on dismiss

Crash Logs:

2018-06-13 16:19:54.450526+0530 PocketRehab[2300:25819] [Common] _BSMachError: port 1e53b; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
2018-06-13 16:19:54.506719+0530 PocketRehab[2300:25819] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modal view controller on itself. Presenting controller is <UISearchController: 0x7feea6635a00>.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000112f941e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x0000000112625031 objc_exception_throw + 48
2 UIKit 0x0000000110021a95 __78-[UIViewController _presentViewController:withAnimationController:completion:]_block_invoke + 0
3 UIKit 0x00000001100242c6 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99
4 UIKit 0x0000000110024958 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511
5 UIKit 0x000000011002422c -[UIViewController _presentViewController:animated:completion:] + 169
6 UIKit 0x0000000110024570 -[UIViewController presentViewController:animated:completion:] + 154
7 UIKit 0x0000000110c25bd9 __51-[UISearchController _performAutomaticPresentation]_block_invoke + 330
8 UIKit 0x0000000110bc7a29 -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 294
9 UIKit 0x0000000110bc36d5 -[_UIViewControllerTransitionContext _runAlongsideCompletions] + 132
10 UIKit 0x0000000110bc33c4 -[_UIViewControllerTransitionContext completeTransition:] + 118
11 UIKit 0x000000010fe754b3 _runAfterCACommitDeferredBlocks + 318
12 UIKit 0x000000010fe6471e _cleanUpAfterCAFlushAndRunDeferredBlocks + 388
13 UIKit 0x000000010fe92ea5 _afterCACommitHandler + 137
14 CoreFoundation 0x0000000112f36607 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
15 CoreFoundation 0x0000000112f3655e __CFRunLoopDoObservers + 430
16 CoreFoundation 0x0000000112f1ab81 __CFRunLoopRun + 1537
17 CoreFoundation 0x0000000112f1a30b CFRunLoopRunSpecific + 635
18 GraphicsServices 0x0000000119403a73 GSEventRunModal + 62
19 UIKit 0x000000010fe6a057 UIApplicationMain + 159
20 PocketRehab 0x000000010f157687 main + 55
21 libdyld.dylib 0x0000000114bc3955 start + 1
22 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

following link helps me to resolved crash
https://stackoverflow.com/questions/46917918/ios-uisearchcontroller-crash-application-tried-to-present-modal-view-controller?rq=1&utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

tableview offset bug

When I start to tap search bar and then dismiss the keyboard it make tableview offset bug

Swift 4.2

General Information

  • NKVPhonePicker Version:

  • iOS Version(s): 12.1

  • Swift Version: 4.2

  • Device or Simulator:

  • Did you check an example:

What happened?

don't work with 4.2

What did you expect to happen?

there is lost for compiler error

if you try it will be very quick if you have fixed it thanks
also it crash when I try to fixed all swift 4.2 issue so please check that too

Dark Mode Support

General Information

  • NKVPhonePicker Version:

  • iOS Version(s):

  • Swift Version:

  • Device or Simulator:

  • Did you check an example:

What happened?

What did you expect to happen?

Is it possible to pre fill the textfield?

I'm trying to pre fill the text field with the current phone number of the user, but the flag is not getting updated and also it's taking the code of US "+1" when the number is "569812312322" that is a Chilean number.

I'm using textfield.text = "569812312322" to pre fill the text field.

What happened?

Flag not getting updated and also wrong country code.

What did you expect to happen?

Set the flag to Chile and keep the correct code "56".

PlaceHolder not shown

General Information

What happened?

Placeholder is not shown even if set it programatically or from storyboard

What did you expect to happen?

Placeholder should shown in text feild

Error: 'inset(by:)' has been renamed to 'UIEdgeInsetsInsetRect(_:_:)'

General Information

  • NKVPhonePicker Version: Not sure, because there is not version in pod file

  • iOS Version(s): 12.0

  • Swift Version: 4.0

  • Device or Simulator: iPhone 11

  • Did you check an example:

What happened?

Error: 'inset(by:)' has been renamed to 'UIEdgeInsetsInsetRect(::)'

pods/NKVPhonePicker/NKVPhonePickerTextField.swift line 267

functions starts

override open func textRect(forBounds bounds: CGRect) -> CGRect {

What did you expect to happen?

How to fix this problem?

How to open NKVFlagView when user click on textField

General Information

  • NKVPhonePicker Version: NA

  • iOS Version(s): 12.0

  • Swift Version: 4.2

  • Device or Simulator: Both

  • Did you check an example: Yes

What happened?

When user click on textField, keyboard was showing but I want to show flagView using MKFlagView

What did you expect to happen?

I want to show flagView using MKFlagView when click on textFIeld and update textFIeld text with selected country name.

Appcenter.ms: Illegal character '?' NKVPhonePicker/Sources/Bundle/Countries.bundle/Images/?.png

General Information

  • NKVPhonePicker Version:
    1.1.0
  • Swift Version:
    4.1

What happened?

Trying to make a build of app on the appcenter.ms got that error:

Start uploading file 'build/Robomed.xcarchive/Products/Applications/Robomed.app/Frameworks/NKVPhonePicker.framework/Countries.bundle/Images/?.png' to server, chunk '1'.
Chunk '1' attempt '2' of file 'build/Robomed.xcarchive/Products/Applications/Robomed.app/Frameworks/NKVPhonePicker.framework/Countries.bundle/Images/?.png' fail to send request to server. Error: Microsoft.VisualStudio.Services.WebApi.VssServiceResponseException: Wildcards are not allowed. ---> Microsoft.TeamFoundation.InvalidPathException: Wildcards are not allowed.
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.d__53.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.d__51.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.FileContainer.Client.FileContainerHttpClient.d__16.MoveNext().
##[error]File upload failed even after retry.

http://joxi.ru/LmGeNNPiwep6nA

Deleted the NKVPhonePicker from the project and build success.
So the problem is files with '?' in name, which is not supported by Microsoft file systems 👎

What did you expect to happen?

Success build without deleting NKVPhonePicker from the project.

Plus Symbol is not centre for country code

General Information

Hope you find here Screen Short : https://prnt.sc/pxwunv

  • NKVPhonePicker Version:
    2.1.10
  • iOS Version(s):
    12.4.2
  • Swift Version:
    4
  • Device or Simulator:
    Device iPhone 6
  • Did you check an example:
    Yes i checked example

What happened?

I have textfield with class of NKVPhonePicker and position is (20, 50, 335, 50), I set up Initial country code as IN ...Here is my code
/*
countryTF?.favoriteCountriesLocaleIdentifiers = ["RU", "ER", "JM"]
countryTF?.rightToLeftOrientation = false
countryTF?.shouldScrollToSelectedCountry = false
countryTF?.flagSize = CGSize(width: 30, height: 50)
countryTF?.enablePlusPrefix = true
let country = Country.country(for: NKVSource(countryCode: "IN"))
countryTF?.country = country
countryTF?.customPhoneFormats = ["IN" : "## #### ### ###"]
*/

  • text is not centre to country code

What did you expect to happen?

If + will centre to Country code it looks good . May be it will helpful to all

Could not build Objective-C module 'NKVPhonePicker'

General Information

  • NKVPhonePicker Version:
    2.0.1
  • iOS Version(s):
    10.13.6
  • Swift Version:
    4.0
  • Device or Simulator:
    Phone XR
  • Did you check an example:
    Yes

What happened?

Could not build Objective-C module 'NKVPhonePicker'

What did you expect to happen?

Obj-c

Is it compatible with obj-c ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.