title: uipopover with uidatepicker delegate not working
body: <p>I have created a popover with datepicker in storyboard which pops when a button is pressed. After a date is selected and done button is pressed, the date has to be sent to the <code>UIViewController</code>.</p>
  
  <p>I have set up protocols and delegate methods as explained by <a href="https://stackoverflow.com/questions/17628104/uidatepicker-in-uipopover-delegate">uidatepicker in uipopover delegate</a> but the delegate method in my viewcontroller is never called up. Am I missing something? Do I need to use segues for this?? Please help!!</p>
  
  <pre><code>- (IBAction)doneButtonPress:(UIBarButtonItem *)sender {
      NSLog(@"donebuttonpress");
      [_delegate receiveDate:pickedDate];
      NSLog(@"afterdelegation");
  }
  </code></pre>
  
  <p>Both the <code>donebuttonpress</code> and <code>afterdelegation</code> are printed, but the method has never been called :(</p>
  
  <p>//selectDatePopover.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  @protocol selectDatePopoverDelegate &lt;NSObject&gt;
      - (void)receiveDate:(NSString *)theDate;
  @end
  
  @interface selectDatePopover : UIViewController{
      id &lt;selectDatePopoverDelegate&gt; delegate;
  }
  
  @property (nonatomic, assign) id &lt; selectDatePopoverDelegate &gt; delegate;
  - (IBAction)doneButtonPress:(UIBarButtonItem *)sender;
  - (IBAction)mydatepicker:(UIDatePicker *)sender;
  @end
  </code></pre>
  
  <p>//selectDatePopover.m</p>
  
  <pre><code>- (IBAction)doneButtonPress:(UIBarButtonItem *)sender {
      NSLog(@"donebuttonpress");
      NSLog(_delegate);
      [_delegate receiveDate:pickedDate];
      NSLog(@"afterdelegation");
  }
  
  - (IBAction)mydatepicker:(UIDatePicker *)sender {
      NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
      [formatter setDateFormat:@"yyyy-MM-dd"];
      pickedDate = [formatter stringFromDate:[sender date]];
      NSLog(pickedDate);
  }
  </code></pre>
  
  <p>//CheckIn_ViewController.h</p>
  
  <pre><code>#import "selectDatePopover.h"
  @interface CheckIn_ViewController : UIViewController &lt;selectDatePopoverDelegate&gt;
      @property UIPopoverController *popover;
  @end
  </code></pre>
  
  <p>//CheckIn_ViewController.m</p>
  
  <pre><code>- (void)receiveDate:(NSString *)theDate {
      NSLog(@"backhere");
      dateLabel.Text = theDate;
  }
  </code></pre>
  
  <p>//On the press on this button, popover has to show up:</p>
  
  <pre><code>- (IBAction)calendarbutton:(UIButton *)sender {
      UIView *anchor = sender;
      selectDatePopover *selectDatePopoverInstance =
      [self.storyboard instantiateViewControllerWithIdentifier:@"selectDatePopover"];
      _popover = [[UIPopoverController alloc] initWithContentViewController:selectDatePopoverInstance];
      [_popover presentPopoverFromRect:anchor.frame
                           inView:anchor.superview
         permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
  
      selectDatePopoverInstance.delegate = self;
  }
  </code></pre>