title: How to dismiss the UIPopoverController?
body: <p>I have created a <code>UIPopoverController</code> and added it to a view controller when clicking an <code>UIButton</code> as follows</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      controller = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]];
      popoverController = [[UIPopoverController alloc] initWithContentViewController:controller];
  }
  
  - (IBAction)showPopover:(UIButton *)sender
  {
      if ([popoverController isPopoverVisible]) {
          [popoverController dismissPopoverAnimated:YES];
      } else {
                 CGRect popRect = CGRectMake(self.btnShowPopover.frame.origin.x,
                                  self.btnShowPopover.frame.origin.y,
                                  self.btnShowPopover.frame.size.width,
                                  self.btnShowPopover.frame.size.height);
            [popoverController presentPopoverFromRect:popRect
                                         inView:self.view
                       permittedArrowDirections:UIPopoverArrowDirectionAny
                                       animated:YES];
      }
  }
  </code></pre>
  
  <p><code>btnShowPopover</code> is the <code>UIButton</code> in the <code>viewcontroller</code>, <code>popoverController</code> is the <code>UIPopoverController</code>. </p>
  
  <p>The <code>popovercontroller</code> appears fine while clicking the button.</p>
  
  <p>But it won't get dismissed when I click the <code>UIButton</code> in the <code>secondviewcontroller</code></p>
  
  <p>I used the following code for that</p>
  
  <pre><code>-(IBAction)y:(id)sender{
      fs =  [[Firstviewcontroller alloc] initWithNibName:@"FIrstscreen" bundle:[NSBundle mainBundle]];
      [fs.popoverController dismissPopoverAnimated:TRUE];
  }
  </code></pre>
  
  <p>But it didn't work.</p>
  
  <p>How to dismiss the <code>popovercontroller</code> when clicking the button in a viewcontoller that was added to the <code>popovercontroller</code>?</p>