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 7035219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:16:43+00:00 2026-05-28T01:16:43+00:00

I have a custom UIView that I am displaying as a callout when the

  • 0

I have a custom UIView that I am displaying as a callout when the user clicks on a custom annotation on an MKMapView.

To achieve this I have subclassed MKAnnotationView and overloaded the -setSelected:selected animated: method as suggested in this answer. Basically, I am adding my custom view as a subview of my MKAnnotationView subclass.

The problem is that I can’t interact with the callout, which contains a button and a scrollable webview, at all. What’s more, if the callout hides an annotation and I press the callout at the approximate location of that hidden annotation, the callout will get dismissed and a new one will be shown.

// TPMapAnnotationView.m
@implementation TPMapAnnotationView
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    if(selected)
    {
        TPMapAnnotation* anno = ((TPMapAnnotation*)self.annotation);
        QuickInfoView* qi = [[QuickTabView alloc] initWithFrame:CGRectMake(0, 0, 440, 300)];
        [qi displayDataForAnnotation:anno];
        [self addSubview:qi];
        // some animiation code that doesn't change things either way
    }
    else
    {
        [[self.subviews objectAtIndex:0] removeFromSuperview];
    }
}

The code below creates the TPMapAnnotationView.

// this is in the view controller that contains the MKMapView
- (MKAnnotationView *) mapView:(MKMapView *) mapView viewForAnnotation:(id) annotation 
{  
    if ([annotation isKindOfClass:[TPMapAnnotation class]])
    {
        TPMapAnnotationView *customAnnotationView = (TPMapAnnotationView *)[myMap dequeueReusableAnnotationViewWithIdentifier:@"TPAnn"];
        if (customAnnotationView == nil)
        {
            customAnnotationView = [[TPMapAnnotationView alloc] initWithAnnotation:annotation 
                                                                reuseIdentifier:@"TPAnn"];
        }
        [customAnnotationView setImage:annotationImage];
        return customAnnotationView;
    }
    return nil; // blue radar circle for MKUserLocation class.
}
  • 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-28T01:16:43+00:00Added an answer on May 28, 2026 at 1:16 am

    This is a well known problem. Anything you add on AnnotationView will not detect touches. There is good open source project for this problem. http://dev.tuyennguyen.ca/wp-content/uploads/2011/03/CustomMapAnnotationBlogPart1.zip, http://dev.tuyennguyen.ca/wp-content/uploads/2011/03/CustomMapAnnotationBlogPart21.zip

    EDIT:
    

    Yes. I also tried hard to add uibuttons to my own custom annotationView but then I stumbled upon this project and found that his custom annotationView is actually a annotation.

    Anyway if you want to to change height of annotatioView then you can set

    - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
    
     calloutMapAnnotationView.contentHeight = height;
     calloutMapAnnotationView.titleHeight = 25;
    }
    

    here, titleHeight is property added to CalloutMapAnnotationView which determines height of “gloss” in drawRectMethod

    - (void)drawRect:(CGRect)rect {
    glossRect.size.height = self.titleHeight;
    }
    

    if you are having any difficulty please let me know.

    And also the link to original blogpost:
    http://dev.tuyennguyen.ca/?p=298

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

Sidebar

Related Questions

I have a UIView that I want to load when the user clicks a
I have a custom UIView that contains an interactive drawing that is drawn in
I have a simple custom UIView (a rectangle) that is implemented with drawRect. The
I have a library that programmatically constructs a UIView that exhibits my custom behavior.
I have a custom UIView that draws an image in the draw rect method.
I have a custom UIView subclass that contains a grid of cells, each of
I have a custom UIView subclass that i'm trying to use as a header
I have a custom UIView class. Inside that view, there is an image view.
I have a custom UIView subclass without a corresponding UIViewController. I use this class
I have a custom view that subclasses UIView. It has a touchesEnded event, however

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.