Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 771341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:38:20+00:00 2026-05-14T18:38:20+00:00

I have a MKMapView (also a UIPopoverControllerDelegate) with Annotations. This MapView has, in the

  • 0

I have a MKMapView (also a UIPopoverControllerDelegate) with Annotations. This MapView has, in the MKTestMapView.h file, a UIPopoverController* popoverController defined in the @interface and a @property (nonatomic, retain) UIPopoverController* popoverController; defined outside of the @interface section. This controller is @synthesized in the MKTestMapView.m file and it is released in the - (void)dealloc section. The Annotations in this MapView have rightCalloutAccessoryViews defined to the following:

- (void)mapView:(MKMapView *)mapView2 annotationView:(MKAnnotationView *)aview calloutAccessoryControlTapped:(UIControl *)control{

...

CGPoint leftTopPoint = [mapView2 convertCoordinate:aview.annotation.coordinate toPointToView:mapView2];

int boxDY=leftTopPoint.y;
int boxDX=leftTopPoint.x;
NSLog(@"\nDX:%d,DY:%d\n",boxDX,boxDY);

popoverController = [[UIPopoverController alloc] initWithContentViewController:controller];
popoverController.delegate = self;
CGSize maximumLabelSize = CGSizeMake(320.0f,600.0f);

popoverController.popoverContentSize = maximumLabelSize;

CGRect rect = CGRectMake(boxDX, boxDY, 320.0f, 600.0f);

[popoverController presentPopoverFromRect:rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];


...

}

Now here comes the fun part. First of all, I am not sure if I need maximumLabelSize and the rect to be the same size. I am new to the popovercontroller so I am playing this by ear..

Okay, the popover shows. Now to dismissing it. I can click anywhere on mapView2 and the popover goes away…but I need the user to click a button in the view if they change anything. URGH!

The docs show:

To dismiss a popover programmatically,
call the dismissPopoverAnimated:
method of the popover controller.

Well, here is the problem: By definition of how the popoverController works, you are clicking inside the view of the displayed popover (to click the button) but have to trigger the dismissPopoverAnimated: method of the controller that launched this popover view, in my case, the popoverController inside the MKTestMapView.m file.

Now, having said all that, remember, [popoverController release] doesn’t happen until:

- (void)dealloc {
 [popoverController release];
 [mapView release];
    [super dealloc];
}

So, do i just do the following inside the button (messy but may work):

(Assuming my popover view is a TableView) In the:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MKTestMapView * mKTestMapView = [[MKTestMapView alloc] init];
[[mKTestMapView popoverController].dismissPopoverAnimated:YES];
}

Here is my issue: I cannot figure out whether doing the above gives me a reference (if there is such a thing) to the existing view that is on the screen — and therefore the view that is the owner of that popoverController. If it is as simple as

[[[self parentView] popoverController].dismissPopoverAnimated:YES];

I will shoot myself cos I don’t think that is the correct syntax either!

This should be easy…yet I am lost. (probably just frustrated with so many iPad differences that I am learning).

Can anyone explain more?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:38:21+00:00Added an answer on May 14, 2026 at 6:38 pm

    I had the same problem… I had a neat “close” button (X) in the top of my view loaded by the popover, but it didn’t work. In my universal app it will be presented as a new view, so that code should stay.

    What I did now was that I added the following to my detailedPinView (the view the popover loads):

    in the detailedPinView.h file:

    @interface detailedPinView : UIViewController {
        [...]   
        UIPopoverController *popover;
        [...]
    }
    
    -(void)setPopover:(UIPopoverController*)aPopover;
    

    In the detailedPinView.m file:

    - (void)setPopover:(UIPopoverController*)aPopover
    {
        popover = aPopover;
    }
    

    The X button closes the view using an IBAction, this is what I did there:

    In the detailedPinView.m file:

    -(IBAction)releaseDetailedView:(UIButton *)sender
    {
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            if (popover != nil)
            {
                [popover dismissPopoverAnimated:YES];
            }
            else {
                NSLog(@"Nothing to dismiss");
            }
        }
        else{
            [self.parentViewController dismissModalViewControllerAnimated: YES];
        }
    }
    

    In the class loading the my map and the popover view I added the following code:

    [...]
    -(void)mapView:(MKMapView *)theMapView annotationView:(MKAnnotationView *)pin calloutAccessoryControlTapped:(UIControl *)control
    {   
        UIViewController *detailController = [[detailedPinView alloc] initWithNibName:@"detailedPinView" 
                                                                               bundle:nil 
                                                                       annotationView:pin];
    
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
    
            UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:detailController];
            [aPopover setDelegate:self];
            [aPopover setPopoverContentSize:CGSizeMake(320, 320) animated:YES];
    
            [detailController setPopover:aPopover];
            [detailController release];
    
            [mapView deselectAnnotation:pin.annotation animated:YES];
    
            self.popoverController = aPopover;
    
            [mapView setCenterCoordinate:pin.annotation.coordinate animated:YES];
    
            [self.popoverController presentPopoverFromRect:CGRectMake(382,498,0,0) inView:self.view  permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
        }
        else
        {
            [self presentModalViewController: detailController animated:YES];
        }
    
    
        [detailController release];
    }
    [...]
    

    I don’t know if the was the answer you were hoping for, I think it might be a bit of a messy way to do it… but giving the time schedule this worked like a charm 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 385k
  • Answers 385k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try Property s = m.getProperty("PreferdUserName").value; If that still doesn't work,… May 14, 2026 at 11:33 pm
  • Editorial Team
    Editorial Team added an answer For the layout, I would suggest that you have an… May 14, 2026 at 11:33 pm
  • Editorial Team
    Editorial Team added an answer Loading the data from feedburner will be what's causing this:… May 14, 2026 at 11:33 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.