不能在swift中使用MICountry picker的dial_code

时间:2017-07-06 08:05:48

标签: ios swift

我正在尝试将MICountrypicker用于国家/地区代码(手机号码)。我提到this link。但它运作不佳。它只显示( - )符号

Screen shot

我的源代码:

@IBAction func codet(_ sender:Any){

    let picker = MICountryPicker { (name, code) -> () in
        print(code)
    }

    // Optional: To pick from custom countries list
    picker.customCountriesCode = ["EG", "US", "AF", "AQ", "AX", "IN","AL","DZ","AS","AD","AO","AI","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY","BE","BZ","BJ","BM","BT","BO","BA","BW","BR","IO","BN","BG","BF","BI","KH","CM","CA","CV","KY","CF","TD","CL","CN","CX","CC","CO","KM","CG","CD","CK","CR","CI","HR","CU","CY","CZ","DK","DJ","DM","DO","EC","EG","SV","GQ","ER","EE","ET","FK","FO","FJ","FI","FR","GF","PF","GA","GM","GE","DE","GH","GI","GR","GL","GD","GP","GU","GT","GG","GN","GW","GY","HT","VA","HN","HK","HU","IS","ID","IR","IQ","IE","IM","IL","IT","JM","JP","JE","JO","KZ","KE","KI","KP","KR","KW","KG","LA","LV","LB","LS","LR","LY","LI","LT","LU","MO","MK","MG","MW","MY","MV","ML","MT","MH","MQ","MR","MU","YT","MX","FM","MD","MC","MN","ME","MS","MA","MZ","MM","NA","NR","NP","NL","AN","NC","NZ","NI","NE","NZ","NU","NF","MP","NO","OM","PK","PW","PS","PA","PG","PY","PE","PH","PN","PL","PT","PR","QA","RO","RU","RW","RE","BL","SH","KN","LC","MF","PM","VC","WS","SM","ST","SA","SN","RS","SC","SL","SG","SK","SI","SB","SO","ZA","SS","GS","ES","LK","SD","SR","SJ","SZ","SE","CH","SY","TW","TJ","TZ","TH","TL","TG","TK","TO","TT","TN","TR","TM","TC","TV","UG","UA","AE","GB","US","UY","UZ","VU","VE","VN","VG","VI","WF","YE","ZM","ZW"]

    // delegate
    picker.delegate = self

    // Display calling codes
    picker.showCallingCodes = true

    // or closure
    picker.didSelectCountryClosure = { name, code in

        //      picker.navigationController?.popToRootViewController(animated: true)

        //  picker.navigationController?.popViewController(animated: true)

        print(code)
    }


    picker.didSelectCountryWithCallingCodeClosure = { name, code, dialCode in
        print(dialCode)
    }
    //   self.navigationController?.setNavigationBarHidden(false, animated: true)
    navigationController?.pushViewController(picker, animated: true)

    }

如果有人知道答案,请给我......;)

1 个答案:

答案 0 :(得分:1)

添加此行picker.showCallingCodes = true