MRCountryPicker 0.0.8

MRCountryPicker 0.0.8

测试已测试
语言语言 SwiftSwift
许可 MIT
发布最后发布2018 年 5 月
SPM支持 SPM

xtrinch 维护。



  • Mojca Rojko

MRCountryPicker

Version Downloads CI Status License Platform Carthage compatible

低于 0.0.4 版本的与 Swift 2.2 兼容,0.0.5-0.0.7 版本的与 Swift 3 兼容,0.0.8+ 版本的与 Swift 4 兼容。

示例

要运行示例项目,克隆仓库,然后首先从 Example 目录运行 pod install 命令。

screen shot 2016-06-11 at 13 00 05

用法

将您的 UIPickerView 设置为 MRCountryPicker 类,设置其 countryPickerDelegate 并实现其 countryPhoneCodePicker 方法。

请参见以下示例

class ViewController: UIViewController, MRCountryPickerDelegate {

    @IBOutlet weak var countryPicker: MRCountryPicker!
    @IBOutlet weak var countryName: UILabel!
    @IBOutlet weak var countryCode: UILabel!
    @IBOutlet weak var countryFlag: UIImageView!
    @IBOutlet weak var phoneCode: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        countryPicker.countryPickerDelegate = self
        countryPicker.showPhoneNumbers = true

        // set country by its code
        countryPicker.setCountry("SI")

        // optionally set custom locale; defaults to system's locale
        countryPicker.setLocale("sl_SI")

        // set country by its name
        countryPicker.setCountryByName("Canada")
    }
    
    // a picker item was selected
    func countryPhoneCodePicker(picker: MRCountryPicker, didSelectCountryWithName name: String, countryCode: String, phoneCode: String, flag: UIImage) {
        self.countryName.text = name
        self.countryCode.text = countryCode
        self.phoneCode.text = phoneCode
        self.countryFlag.image = flag
    }

}

安装

MRCountryPicker 可通过 Cocoapods 和 Carthage 获取。

CocoaPods

请将以下行添加到您的Podfile中

pod 'MRCountryPicker', '~> 0.0.8'

Carthage

请将以下行添加到您的Cartfile中

github "xTrinch/MRCountryPicker" ~> 0.0.8

作者

xtrinch, [email protected]

在朋友的帮助下完成
https://github.com/marmelroy/PhoneNumberKit
https://github.com/Keyflow/CountryPicker-iOS-Swift
https://github.com/nicklockwood/CountryPicker

许可

MRCountryPicker遵循MIT许可。有关更多信息,请参阅LICENSE文件。