title: Unable to scroll in uipicker view in iOS?
body: <p>I have created a XIB file for picker view &amp; now on tap gesture i am adding the picker view on superview. It is added successfuly but I am not able to scroll.I have also added two button for cancel &amp; done but none of the action for those buttons are detected. Kindly let me know what is the issue </p>
  
  <p>Here is code for adding uipicker view.</p>
  
  <pre><code>@objc  func didRecognizeTapGesture(_ gesture: UITapGestureRecognizer) {
  
  
      let frame:CGRect = CGRect(x: 0, y: self.view.frame.height + 200, width: self.view.frame.width, height: 200)
      self.itemPicker = ItemPicker.instanceFromNib(with: frame) as? ItemPicker
      self.itemPicker?.configureView(frame: frame)
      self.view.addSubview(self.itemPicker!)
      self.itemPicker?.itemPickerDelegate = self
      showView()
  }
  
  func showView() {
      UIView.animate(withDuration: 0.2) {
  
          self.itemPicker?.frame = CGRect(x: 0, y: self.view.frame.height - 200, width: self.view.frame.width, height: 200)
      }
  }
  
  func hideView() {
      UIView.animate(withDuration: 0.2) {
          self.itemPicker?.frame = CGRect(x: 0, y: self.view.frame.height, width: self.view.frame.width, height: 200)
  
      }
  }
  </code></pre>
  
  <p>Code for class picker view </p>
  
  <pre><code>protocol ItemPickerDelegate {
  
      func pickerCancelled()
      func pickerDone()
      func itemPicked(with item:String)
  
  }
  
  class ItemPicker: UIPickerView {
  
      /// IBOutlets
      @IBOutlet weak var pickerView: UIPickerView!
      var itemPickerDelegate:ItemPickerDelegate!
      var arrItems:[String] = ["Item1","Item2","Item3","Item5","Item6"]
  
      class func instanceFromNib(with frame:CGRect) -&gt; UIView {
          let view = Bundle.main.loadNibNamed(Titles.XIB.itemPicker, owner: self, options: nil)! [0] as! UIView
          return view
      }
  
      func configureView(frame:CGRect) {
          self.frame = frame
          self.pickerView.delegate = self
          self.pickerView.dataSource = self
      }
  
      //MARK:IBActions
      @IBAction func actionCancel(_ sender: Any) {
          DILog.print(items: "actionCancel")
          self.itemPickerDelegate.pickerCancelled()
      }
  
      @IBAction func actionDone(_ sender: Any) {
          DILog.print(items: "actionDone")
          self.itemPickerDelegate.pickerDone()
      }
  }
  
  extension ItemPicker:UIPickerViewDelegate {
  
  
      func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
  
      }
  
      func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -&gt; String? {
  
          return arrItems[row]
      }
  }
  
  
  extension ItemPicker:UIPickerViewDataSource {
  
      func numberOfComponents(in pickerView: UIPickerView) -&gt; Int {
  
          return 1
      }
  
      func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
  
          return arrItems.count
  
      }
  
  }
  </code></pre>
  
  <p>Kindly help me out with this problem.</p>