UIPickerView for each text field with different arrays (Swift/Firebase)

前端 未结 2 690
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-13 16:36

I am trying to create a form in which each text field has a UIPickerView which the user can use to select the option needed. I need a to use a different array of information

2条回答
  •  不思量自难忘°
    2021-01-13 16:40

    you can assign your selected value to particular text field by using textField delegate methods which is textFieldDidBeginediting which is called when textField did started begin editing

    like

    take one variable

    var textFieldSelected = UITextField()
    

    and then in

    func textFieldDidBeginEditing(_ textField: UITextField) {
        textFieldSelected = textField
    }
    

    by doing this you will get you selected textField

    and when you done choosing from picker

    func doneSelection(){
        if textFieldSelected == yourTextField(in which you want to enter your data)
        {
            yourTextField.text = data you want to enter from picker
        }
    }
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题