list of countries into uipickerview swift 3

后端 未结 1 393
鱼传尺愫
鱼传尺愫 2021-01-23 15:03

I googled how to find the list of the countries and trying to implement into PickerView, but I am stuck at this point where I try to do countries.count

相关标签:
1条回答
  • 2021-01-23 15:49

    You need to return array count in method numberOfRowsInComponent and in the titleForRow you need to return array object, show that it will show in picker.

    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]
    }
    
    0 讨论(0)
提交回复
热议问题