How to use one UIPickerView for multiple textfields in one view?

后端 未结 4 2073
予麋鹿
予麋鹿 2020-12-06 18:11

I have 8 textfields in one view. I want to populate each using a pickerview. Can I have 1 pickerview which will display different list of items from different arrays for dif

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 19:05

    1.Use a toolBar with Done barButtonItem,which should hide the pickerView.

    2.Now give your textFields tagValues like : textFiled1.tag=100; then using this tag value populate your pickerView array.

    3.When the user selects any Value from pickerView, in its delegate method write

    if(textField.tag== @"Your Tag Value")
    {  
          textField.text=[pickerArray objectAtIndex:row];
    }
    

    I guess you can try the code yourself, now that you have the gist of the solution.Good Luck!!

提交回复
热议问题