title: how do i show date picker when clicked on textfield
body: <blockquote>
    <p>this is my code</p>
  </blockquote>
  
  <pre><code>- @IBOutlet weak var txt1: UITextField!
  
     @IBOutlet weak var txt2: UITextField!
  
     @IBOutlet weak var txt3: UITextField!
  
     @IBOutlet weak var txt4: UITextField!
  
     @IBOutlet weak var txt5: UITextField!
  
     @IBOutlet weak var txt6: UITextField!
  
     @IBOutlet weak var txt7: UITextField!
  
     @IBOutlet weak var picker: UIPickerView!
  
  
     var category = ["Male", "Female", "Others"]
  
     let datePicker = UIDatePicker()
  
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do any additional setup after loading the view, typically from a nib.
  
         picker.isHidden = true
  
         txt3.delegate = self
  
         self.txt3.inputView = picker
  
         //txt3.inputView  = category[row]
     }
  
     // returns the # of rows in each component..
     func pickerView(pickerView: UIPickerView!, numberOfRowsInComponent component: Int) -&gt; Int{
         return category.count
     }
  
     func pickerView(pickerView: UIPickerView!, titleForRow row: Int, forComponent component: Int) -&gt; String! {
         return category[row]
     }
  
     func pickerView(pickerView: UIPickerView!, didSelectRow row: Int, inComponent component: Int)
     {
         txt3.text = category[row]
        // category.isHidden = true;
     }
  
     func textFieldShouldBeginEditing(textField: UITextField) -&gt; Bool {
         if textField == txt3 {
             //resignFirstResponder()
             //picker.isHidden = true
                   }
         return true
         }
     }
  
  
     @IBAction func txt3(_ sender: Any) {
         func showDatePicker(){
             //Formate Date
             datePicker.datePickerMode = .date
  
  
             //ToolBar
             let toolbar = UIToolbar();
             toolbar.sizeToFit()
  
             //done button &amp; cancel button
             let doneButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.bordered, target: self, action:
    Selector(("donedatePicker")))
             //let spaceButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil)
            // let cancelButton = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.bordered, target: self, action:
     Selector("cancelDatePicker"))
             toolbar.setItems([doneButton], animated: false)
  
             // add toolbar to textField
             txt3.inputAccessoryView = toolbar
             // add datepicker to textField
             txt3.inputView = datePicker
  
         }
  
         func donedatePicker(){
             //For date formate
             let formatter = DateFormatter()
             formatter.dateFormat = "dd/MM/yyyy"
             txt3.text = formatter.string(from: datePicker.date)
             //dismiss date picker dialog
             self.view.endEditing(true)
         }
  
         func cancelDatePicker(){
             //cancel button dismiss datepicker dialog
             self.view.endEditing(true)
         }
  
     override func didReceiveMemoryWarning() {
         super.didReceiveMemoryWarning()
         // Dispose of any resources that can be recreated.
     }
  </code></pre>
  
  <blockquote>
    <p>Blockquote</p>
  </blockquote>