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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:37:58+00:00 2026-06-15T19:37:58+00:00

I have added a button to my annotation view, and it appears correctly. When

  • 0

I have added a button to my annotation view, and it appears correctly. When the button is tapped, I want a call to be made, but when I tap the button, it doesn’t respond (the button doesn’t even highlight). It seems that the button doesn’t receive the touch event, but I don’t know why.

Here is my code in customAnnotationView.m

- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier
{
    NSLog(@"initWithAnnotation start");

    //initialze the view
    self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
    if (self != nil)
    {
        CGRect frame = self.frame;
        frame.size = CGSizeMake(60.0, 85.0);
        self.frame = frame;
        self.backgroundColor = [UIColor clearColor];
        self.centerOffset = CGPointMake(30.0, 42.0);
    }

    //this has nothing to do with my question
    self.title=[[[NSString alloc] init] autorelease];
    self.description=[[[NSString alloc] init] autorelease];
    self.phoneNumber=[[[NSString alloc] init] autorelease];
    customAnnotation * tempCust = (customAnnotation *)annotation;       
    self.title=annotation.title;
    self.description=tempCust.description;
    self.phoneNumber=tempCust.phoneNumber;

    //here is the question button
    self.userInteractionEnabled=YES;
    self.exclusiveTouch=NO;
    UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button setTitle:@"Call" forState:UIControlStateNormal];
    //decide the button's position
    CGRect rect=button.frame;
    rect.origin.x=15;
    rect.origin.y=47;
    rect.size.width=40;
    rect.size.height=20;
    button.frame=rect;
    [self addSubview:button];

    [button becomeFirstResponder];

    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];



    NSLog(@"initWithAnnotation finished");

    return self;
}

//action method
-(void)buttonClicked:(id)sender{
    NSString *callNumber=[[[NSString alloc] initWithFormat:@"tel://%@",self.phoneNumber] autorelease];
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:callNumber]];
}

Why doesn’t the button work?

  • 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-15T19:38:00+00:00Added an answer on June 15, 2026 at 7:38 pm
    self.rightCalloutAccessoryView = button;
    

    Use the above instead of [self addSubview:button];

    Hope this help’s you

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

Sidebar

Related Questions

i have added a detail button on my pin annotation. i want to go
I have added button to datagrid view but when ever the function is called
I have added a button to a template for a ListBoxItem. I want to
I have added an image for my button,but when I run that frame this
I have added a border to a button on mouse hover but this disturbs
In my VIew, i have added a button and when i click on it,
I have created an asp.net mvc 3 razor view and added data annotation attributes
I have added a button inside a loginview, but then this code is not
I'm using ATK4 4.1.1 and have added a button to a page. I want
I am using pygtk dialog, i have added a button and i now want

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.