如何使用一个UIPickerView在同一个UIView中显示多个Picker

时间:2017-03-31 03:36:13

标签: ios swift uipickerview

我是iOS开发的初学者,我想创建一个小的iOS应用程序。在这个页面上,我需要使用一个UIPickerView在UIView中创建多个选择器。但是,我不知道运行时间之前的选择数量。

现在: This is the original

我想这样做: The amount of picker is unknown before run time

代码:

 @IBOutlet weak var Pickers: UIPickerView!
override func viewDidLoad() {
   for index in 1...neverCount{
   array.append(String(index))
       }
   }
func pickerView(_ pickerView: UIPickerView,titleForRow row:Int,forComponent component:Int ) -> String!{

    return array[row]
}
 func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {

    print(self.array[pickerView .selectedRow(inComponent: 0)])

    self.choice = Int(self.array[pickerView .selectedRow(inComponent: 0)])!
}
func pickerView(_ pickerView: UIPickerView,numberOfRowsInComponent component:Int ) -> Int{
    return array.count
}
 func numberOfComponents(in pickerView: UIPickerView) -> Int {
    return 1
}

英语不是我的母语,请原谅我的任何错误。

0 个答案:

没有答案