Multiple UIPickerView in the same UIView

后端 未结 5 1527
暖寄归人
暖寄归人 2021-02-01 20:24

I\'m a complete beginner on iOS dev and I want to create a little iOS application. On this application, 3 UIPickerViews are supposed to display different data.

5条回答
  •  清酒与你
    2021-02-01 20:48

    You don't need tags, just use:

     func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int{
            if pickerView == pickerView1 {
                //pickerView1
            } else if pickerView == pickerView2{
               //pickerView2
            }
    

    also don't forget to set delegate in IB or in code:

    pickerView1.delegate = self
    

提交回复
热议问题