PhoneNumberKit
PhoneNumberKit copied to clipboard
Unable to dismiss country picker when presented modally.
When i use below line to present modally. it do not dismiss when clicked on the country cell in CountryCodePickerViewController.
PhoneNumberKit.CountryCodePicker.forceModalPresentation = true
@DhavalBhimani can you provide more information, such as what version of iOS, Xcode, version number for PhoneNumberKit, etc. ?
It can be difficult to help out if we can’t reproduce the issue first.
I also have this issue. iOS version 13.1.3, PhoneNumberKit version 3.2.0. When the user selects country code, it doesn't close CountryCodePickerViewController, but behind him, it goes to the previous view controller in the NavigationController stack. I fixed this by changing string 459 in the TextField.swift from
if let nav = containingViewController?.navigationController {
to
let nav = containingViewController?.navigationController if nav != nil && PhoneNumberKit.CountryCodePicker.forceModalPresentation == false {
But probably I set forceModalPresentation in the wrong way initially? I added to viewDidLoad() of my view controller these strings:
PhoneNumberKit.CountryCodePicker.commonCountryCodes = ["it", "ru", "ua", "us"] PhoneNumberKit.CountryCodePicker.forceModalPresentation = true
Hi I have also faced with this issue. Can you also make navigation controller public property, there is any possibility to customise it, just UINavigationController in following code:
@objc func didPressFlagButton() { guard withDefaultPickerUI else { return } let vc = CountryCodePickerViewController(phoneNumberKit: phoneNumberKit) vc.delegate = self if let nav = containingViewController?.navigationController, !PhoneNumberKit.CountryCodePicker.forceModalPresentation { nav.pushViewController(vc, animated: true) } else { let nav = UINavigationController(rootViewController: vc) containingViewController?.present(nav, animated: true) } }
If the containingViewController has a navigation controller and countryCodePicker is forced presented modally, the view is not dismissed. Needs fixing!!!
Anyone have a clue on how to present this in SwiftUI?
This statement in countryCodePickerViewControllerDidPickCountry(_:)
of CountryCodePickerDelegate
seem out of place.
if let nav = containingViewController?.navigationController {
nav.popViewController(animated: true)
} else {
containingViewController?.dismiss(animated: true)
}
It should call for dismissal at tableView(_:, didSelectRowAt:)
of CountryCodePickerViewController
instead.
Current code dismisses presenting vc, not modally presented one.
+1, I have same issue
Does anyone want to open a PR fixing it?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.