title: Multiple pickerviews with multiple textfield inputviews Swift
body: <p>I've been searching through the forum and nothing has helped.
  I am using 4 text fields in one view controller, and for each textfield, I am using a separate pickerView as the inputViews for the textFields (4pickers).</p>
  
  <p>When I click on the first textField, pickerView1 successfully appears and the textfield displays the data, however when I click on the second, third and fourth textfields,the first pickerView appears.
  I suspect the error lies in the inputView declarations.</p>
  
  <p>And I would so appreciate it if you could help add a "done" button to the pickerView.</p>
  
  <p>My code: </p>
  
  <pre><code>class ViewController1: UIViewController, UIPickerViewDelegate
  {
  
      @IBOutlet var pickerView1: UIPickerView!
      @IBOutlet var pickerView2: UIPickerView!
      @IBOutlet var pickerView3: UIPickerView!
      @IBOutlet var pickerView4: UIPickerView!
  
      @IBOutlet var textField1: UITextField!
      @IBOutlet var textField2: UITextField!
      @IBOutlet var textField3: UITextField!
      @IBOutlet var textField4: UITextField!
  
      var hazards = ["a","b", "c"]
      var reasons = ["d", "e", "f"]
      var site = ["v","h","i","j"]
      var line = ["k", "l","m", "n"]
  
      override func viewDidLoad() {
  
          super.viewDidLoad()
          pickerView1 = UIPickerView()
          pickerView2 = UIPickerView()
          pickerView3 = UIPickerView()
          pickerView4 = UIPickerView()
          pickerView1.delegate = self
          pickerView2.delegate = self
          pickerView3.delegate = self
          pickerView4.delegate = self
  
          self.textField1.inputView = self.pickerView1;
          self.textField2.inputView = self.pickerView2;
          self.textField3.inputView = self.pickerView3;
          self.textField4.inputView = self.pickerView4;
      }
  
      func numberOfComponentsInPickerView(pickerView: UIPickerView) -&gt; Int  {
          return 1
      }
  
      func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
  
          if pickerView.tag == 0 {
              return hazards.count
          } else if pickerView.tag == 1 {
              return reasons.count
          } else if pickerView.tag == 2 {
              return  site.count
          } else if  pickerView.tag == 3 {
              return line.count
          }
          return 1
      }
  
      func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -&gt; String! {
  
          if pickerView.tag == 0 {
              return hazards[row]
          } else if pickerView.tag == 1 {
              return reasons[row]
          } else if pickerView.tag == 2 {
              return site[row]
          } else if pickerView.tag == 3 {
              return line[row]
          }
  
          return ""
      }
  
      func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)  {
  
          if pickerView.tag == 0 {
              textField1.text = hazards[row]
          } else if pickerView.tag == 1 {
              textField2.text = reasons[row]
          } else if pickerView.tag == 2 {
              textField3.text = site[row]
          } else if pickerView.tag == 3 {
              textField4.text = line[row]
          }
      }
  }
  </code></pre>