     }
   }
   
+  // Send a ValueChanged event to the receiver (if assigned) 
+  // and call the delegate's didFinishEditing method (if appropriate).
+  private func sendValueChanged() {
+    sendActionsForControlEvents(.ValueChanged)
+    delegate?.textFieldDidEndEditing?(self)
+  }
+  
   // Actually pop up a picker, then update date from picked value.
   public func pop() {
-    if viewController == nil {
+    if popupContainer == nil {
       return;
     }
     

//  Copyright © 2015 Michael Chaffee. All rights reserved.
//

/*
This custom control is a read-only UITextField which, when touched, raises a DatePickerPop and, after user entry,
places that picker's value in its own text with its dateStyle property's style.
*/
import UIKit

public class DatePickerTextField: UITextField {

      if newValue != _date {
        _date = newValue
        renderDate()
        sendValueChanged()
      }
    }
  }
