title: Swift UIDatePicker for text field input - how to make UIDatePicker disappear?
body: <p>This is my first ever attempt at Swift or an iPhone app, so needless to say I'm not sure how to do many things at this point. </p>
  
  <p>Right now I have a view controller with a text field and a button. I've managed to find example code to almost accomplish what I need. I'd like to do the following:</p>
  
  <ol>
  <li>When I click into the text field have a <code>UIDatePicker</code> come on screen.</li>
  <li>Set the <code>UIDate</code> picker to display time only - not a date.</li>
  <li>Put the selected <code>UIDatePicker</code> time in the textfield.</li>
  <li>Have the <code>UIDatePicker</code> go away when I click on the button.</li>
  </ol>
  
  <p>1 through 3 is working. But I can't figure out how to have the <code>UIDatePicker</code> go away and still come back on the screen if I click into the text field again.</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
  
      @IBOutlet weak var dateField: UITextField!
  
      @IBAction func dateField(sender: UITextField) {
  
          var datePickerView  : UIDatePicker = UIDatePicker()
          datePickerView.datePickerMode = UIDatePickerMode.Time
          sender.inputView = datePickerView
          datePickerView.addTarget(self, action: Selector("handleDatePicker:"), forControlEvents: UIControlEvents.ValueChanged)
  
      }
      @IBAction func DoneButton(sender: UIButton) {
  
          //How to make datepicker disappear???
      }
  
      func handleDatePicker(sender: UIDatePicker) {
          var timeFormatter = NSDateFormatter()
          timeFormatter.dateStyle = .NoStyle
          timeFormatter.timeStyle = .ShortStyle
          dateField.text = timeFormatter.stringFromDate(sender.date)
      }
  
      override func viewDidLoad() {
       super.viewDidLoad()
       // Do any additional setup after loading the view, typically from a nib.
  
      }
  
  }
  </code></pre>