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

  • SEARCH
  • Home
  • 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 8884531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:04:57+00:00 2026-06-14T21:04:57+00:00

In iOS6 I am trying to create a custom callout for an annotation that

  • 0

In iOS6 I am trying to create a custom callout for an annotation that will contain detail like, image, title, description etc. I have seen relevant posts here but aren’t what I am looking for. In my app, when you are selecting an annotation, you have a choice of 4 buttons. Now I am trying to create the option for 4th button which is the detailed callout.

I have create a UIView class that represents the custom callout.

EDIT:

After help from Live2Enjoy7 I have modified my code as below.

BuildingViewController.m

- (void)MapMenu:(MapMenu *)menu didSelectButton:(NSInteger)index{

    if (index == 3) {

        image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
        _buildingShowCallout = YES;
        [parentView removeAnnotation:self];
        [parentView addAnnotation:self];
    }
}

If user press the button, this method, create new image (using url link), setting the _buildingShowCallout = YES and finally removing and adding again the selected annotation in order to make viewForAnnotation method to act.

In my MapViewController.m

- (MKAnnotationView *)mapView:(MKMapView *)_mapView viewForAnnotation:(id<MKAnnotation>)annotation{

    if ([annotation isKindOfClass:[MKUserLocation class]]) {
        return nil;
    }

    static NSString *identifier = @"MyAnnotation";
    MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];

    BuildingViewController* building = (BuildingViewController*) annotation;

    // If a new annotation is created
    if (annotationView == nil) {

        annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:building reuseIdentifier:identifier];

        if (building.buildingShowCallout) {// Create the custom callout
            BuildingCallOut* buildingCallout = [[BuildingCallOut alloc]initWithFrame:CGRectMake(0, 0, 200, 150)];
            [buildingCallout showCallout:building];
            [annotationView addSubview:buildingCallout];//add the new callout as subview of the selected annotation.
        }

    } else{

        annotationView.annotation = annotation;

        if (building.buildingShowCallout) {// Create the custom callout
            BuildingCallOut* buildingCallout = [[BuildingCallOut alloc]initWithFrame:CGRectMake(0, 0, 200, 150)];
            [buildingCallout showCallout:building];
            [annotationView addSubview:buildingCallout];//add the new callout as subview of the selected annotation.
        }
    }

    return annotationView;
}

That’s working fine BUT now I have one new problem.

  1. If you select to see a callout for one annotation and then select to see a callout for another annotation, the previous one stays on the map. How I can solve this?

Screenshot
![enter image description here][1]

As you can see.. the previous callout on the top of the screen remains when I am calling the new one at the bottom. Struggling to find where to put the “disappear” line.
Thanks in advance

  • 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-06-14T21:04:58+00:00Added an answer on June 14, 2026 at 9:04 pm

    I’m guessing your BuildingViewController is your MapViewController.

    You want to declare it as an MKMapViewDelegate in your header. This will give you access to several methods that will allow you to change the view of the annotation that appears and even the pin.

    First, import MapKit/MapKit.h and UIKit/UIKit.h if you aren’t already.

    Second, declare that your BuildingViewController conforms to the MKMapViewDelegate protocol (as stated above).

    Third, declare your BuildingViewController as the map view’s delegate in ViewDidLoad like:

    self.mapView.delegate=self; //assuming that the you have a MKMapView named MapView in your layout
    

    Fourth, implement these protocol methods:

    -(MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation;
    
    -(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view;
    

    First method allows you to set right and left call out accessories as well as modify bunch of other things (this is where you want to do you CGRectMakes).

    In second method, you decide what data actually gets displayed in the annotation view.

    Search the documentation for MKMapViewDelegate –> here

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

Sidebar

Related Questions

I'm trying to set 5 custom variables for Google Analytics like so: <script> //<![CDATA[
I'm trying to use the new iOS6 UIActivityViewController and it works fine except that
I am trying to make our App work on iOS6, but there is a
So I am trying to link to a Facebook page on iOS6 from my
I have an older app that does not use ARC. When trying to address
I updated to Xcode 4.5 and am working with iOS6--a mistake I will definitely
How long after iOS 6 comes out that developers HAVE to submit using iOS6?
Trying to update our app for iOS6 and iPhone 5, we (for now) still
I am trying to use EGOTableViewPullRefresh in my ios6 project but I can't get
I am trying to check whether client opening the page is using iOS6 or

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.