title: iPad dismiss popover with button within the popover itself
body: <p>I have a button in my popover controller. I want to use it to dismiss the popover, so I am trying to access a method (dismissPopover) of the presenting view controller (the "root" view controller).</p>
  
  <p><strong>Note:</strong> the method to dismiss the popover is already set up and working, in the root VC, which is the delegate. If I call it it will dismiss the popover. I just need to access the method from the popover. </p>
  
  <p>To do this I set up a property in the AppDelegate, and get an instance of the rootVC like this: <code>self.rootController = (ViewController*)self.window.rootViewController;</code>. Then I imported the root VC class and the AppDelegate to the popover's view controller's class, as below. Seems to give me access to the rootVC, and the methods, but the results do not fire the method. Any idea what I am missing here?</p>
  
  <pre><code>#import "ViewController.h"
  #import "AppDelegate.h"
  </code></pre>
  
  <p>Action connected to button:</p>
  
  <pre><code>- (IBAction)dismissPopover:(id)sender {
  
  //Checking the button works, it does:
  NSLog(@"dismissPopover, from popover");
  
  //Trying to get an instance of the rootViewController, the "presenting view controller"                                  
  ViewController *rootVC = [(AppDelegate *)[[UIApplication sharedApplication] delegate] rootController];
  
  //trying to access the method in the rootVC that dismisses the popover
  [rootVC dismissPopover];
  
  //Tried the following code, does nothing:
  //[self dismissPopoverAnimated:YES];
  }
  </code></pre>
  
  <p><strong>NOTE:</strong> I ended up abandoning the use of a popover for this as it became a bit over complicated. I tried loading my view controller into a UIView (so I could load the contents of a nib to a pop-up view). That also became a bit complicated. So, for now I am just building my desired interface in a UIView programatically. So far works great.</p>