My code bellow is a uitextfiled that uses a picker view to display a and b. All I want to do is have the is have the same picker view appear for all of the textfields using outlet collection. Textfield is the single textField and mutlipleTextifeld is the outlet collection the one I want to use. I I just want to replace textField with mutlipleTextifield.
import UIKit
class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
let picker = UIPickerView()
let country = ["a","b"]
@IBOutlet var textField: UITextField!
@IBOutlet var mutlipleTextifeld: [UITextField]!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
picker.delegate = self
picker.dataSource = self
textField.inputView = picker
}
public func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return country.count
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return country[row]
}
public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
textField.text = country[row]
self.view.endEditing(false)
}}