国家列表到uipickerview swift 3

时间:2016-11-25 04:42:08

标签: arrays swift3 uipickerview

我用谷歌搜索了如何查找国家/地区列表并尝试实施public void process(){ addInfoMsg(summary, msgDetail); //Add msg func RequestContext.getCurrentInstance().execute("setTimeout(function(){ $('#rdr-btn').click(); }, 3000);"); // 3 seconds delay. I put the script in Constants to config later. } ,但我仍然陷入这一点,我尝试PickerView它给了我一个错误说:

  

无法转换类型' int'的返回表达式返回类型' string'   有什么建议吗?

countries.count

1 个答案:

答案 0 :(得分:2)

您需要在方法numberOfRowsInComponent中返回数组计数,并在需要返回数组对象的titleForRow中显示它将显示在选择器中。

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
    return countries.count
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
    return countries[row]
}