0

I have a root view controller in which I load a sub view that contains three buttons. When I touch one of them a popover is shown. The popover contains an image view and a bar with a Done button. I want to dismiss this popover when the Done button is touched. To accomplish this I am using this code

- (IBAction)btnDone:(UIBarButtonItem *)sender {
    [self.view removeFromSuperview];

        [APPDELEGATE.parkDetail. popoverController dismissPopoverAnimated:YES];
   // [APPDELEGATE.parkDetail.popoverController dismissPopoverAnimated:YES ];


}

and the popover is presented like this

- (IBAction)btnParkMap:(id)sender {
       [popoverController dismissPopoverAnimated:YES];
    if ([popoverController isPopoverVisible]) {
        [popoverController dismissPopoverAnimated:YES];
    } else {
        parkMap * v = [[parkMap alloc]initWithNibName:@"parkMap" bundle:nil];
        v.contentSizeForViewInPopover = CGSizeMake(350, 300);
        popoverController = [[UIPopoverController alloc] initWithContentViewController:v];
               CGRect popRect = CGRectMake(self.btnShowPopover.frame.origin.x+330,
                                    self.btnShowPopover.frame.origin.y+170,
                                    self.btnShowPopover.frame.size.width,
                                    self.btnShowPopover.frame.size.height);


        [popoverController presentPopoverFromRect:popRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
          }
}
tkanzakic
  • 5,499
  • 16
  • 34
  • 41
iOS developer
  • 110
  • 1
  • 8

5 Answers5

3

Try this code

[self dismissViewControllerAnimated:YES completion:nil];

Or try @nirav's ans

Shyantanu
  • 681
  • 1
  • 12
  • 30
1

Try to write below code

[yourPopOverobject dismissPopoverAnimated:YES];

Let me know whether it is working or not..

Happy Coding!!!!!

NiravPatel
  • 3,260
  • 2
  • 21
  • 31
1

The PopUpOver can beswitch off the default contextual menu of UIWebView. This is easy because we only need to set the CSS property “-webkit-touch-callout” to “none” for the body element of the web page. We can do this using JavaScript in the UIWebView delegate method “webViewDidFinishLoad:”…

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];
}
0
    - (IBAction)btnDone:(UIBarButtonItem *)sender {

      [self dismissViewControllerAnimated:YES completion:nil];


    }
Rose
  • 437
  • 2
  • 9
0

Try to check below code...

if ([popoverobject isPopoverVisible]) {
   [popoverobject dismissPopoverAnimated:YES];
   [popoverobject release];
}

}

#pragma mark -
#pragma mark UIPopoverController delegate

-(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
 //if (popoverController == popoverobject) {
    [popoverobject release];
 //  }
}

- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController {

   NSLog(@\"popover about to be dismissed\");
   return YES;
  }

let me know is it working or not...

NiravPatel
  • 3,260
  • 2
  • 21
  • 31
  • in the same class where you want to dismiss the popover controller – NiravPatel Nov 28 '12 at 11:42
  • i have told you everything that i know man...i think you have miss some code but you are not finding that..check your code again.. – NiravPatel Nov 28 '12 at 12:25
  • http://www.readncode.com/blog/how-to-dismiss-popovers-in-ios/ http://stackoverflow.com/questions/8656348/ios-how-to-dismiss-popovers http://stackoverflow.com/questions/9253878/how-to-dismiss-popovers-in-ios-5 may be this links help you..try it – NiravPatel Nov 28 '12 at 12:26