I have this code that allows me to make a dropdown list with a textbox, but I need to replicate it with 4 more textboxes on the same screen and if I try to copy the functions as they are I get errors like the same options in each textbox. Any ideas?
class CarritoFinalViewController: UIViewController {
@IBOutlet weak var txtfieldTAM: UITextField!
@IBOutlet weak var textfieldMASA: UITextField!
@IBOutlet weak var textfieldCHEESE: UITextField!
@IBOutlet weak var textfieldING1: UITextField!
@IBOutlet weak var textfieldING2: UITextField!
@IBOutlet weak var textfieldING3: UITextField!
@IBOutlet weak var TotalBillLable: UILabel!
let tamanio = ["Pequeña", "Mediana", "Grande"]
let masa = ["Fina", "Gruesa", "Bordes rellenos"]
let queso = ["Parmesano", "Chedar", "Mozarela"]
let ing1 = ["Ninguno","Más queso", "Pollo", "Huevo"]
let ing2 = ["Ninguno","Más queso", "Pollo", "Huevo"]
let ing3 = ["Ninguno","Más queso", "Pollo", "Huevo"]
var pickerview = UIPickerView()
//SEPARACIÓN
var activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView()
var shoppingCart: CarritoViewController!
override func viewDidLoad() {
super.viewDidLoad()
pickerview.delegate = self
pickerview.dataSource = self
txtfieldTAM.inputView = pickerview
txtfieldTAM.textAlignment = .center
}
}
extension CarritoFinalViewController: UIPickerViewDelegate, UIPickerViewDataSource {
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return tamanio.count
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return tamanio[row]
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
txtfieldTAM.text = tamanio[row]
txtfieldTAM.resignFirstResponder()
}
}
Thanks!!