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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:10:40+00:00 2026-06-09T00:10:40+00:00

I have a UIAlertView which appears as a confirmation when a user wants to

  • 0

I have a UIAlertView which appears as a confirmation when a user wants to delete a RegionAnnotation.

I’m having trouble figuring out how to access the RegionAnnotationView that called the UIAlertView which I need in order to delete the RegionAnnotation.

Here’s my broken code – you can see where I’m trying to cast the AlertView’s superview into a RegionAnnotationView (an admittedly bad idea).

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex==0)
    {
        NSLog(@"alertView.superview is a %@",alertView.superview);
        RegionAnnotationView *regionView = (RegionAnnotationView *)alertView.superview;
        RegionAnnotation *regionAnnotation = (RegionAnnotation *)regionView.annotation;

        [self.locationManager stopMonitoringForRegion:regionAnnotation.region];
        [regionView removeRadiusOverlay];
        [self.mapView removeAnnotation:regionAnnotation];    
    }

}
  • 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-09T00:10:41+00:00Added an answer on June 9, 2026 at 12:10 am

    Since the annotation is selected before the user can delete it, you can get a reference to the annotation from the map view’s selectedAnnotations property.

    In the alert view delegate method, you can do something like this:

    if (mapView.selectedAnnotations.count == 0)
    {
        //shouldn't happen but just in case
    }
    else
    {
        //since only one annotation can be selected at a time,
        //the one selected is at index 0...
        RegionAnnotation *regionAnnotation 
           = [mapView.selectedAnnotations objectAtIndex:0];
    
        //do something with the annotation...
    }
    

    If the annotation wasn’t selected, another simple alternative is to use an ivar to hold a reference to the annotation that needs to be deleted.

    Another option as MSK commented is to use objc_setAssociatedObject.

    Regardless, using the superview assuming the view hierarchy is in a certain way is not a good idea.

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

Sidebar

Related Questions

I have UIAlertView which holds an UIImage and two default buttons OK and Cancel
I'm having some trouble with either a UIAlertView or UIActionSheet stealing the focus and
Hi :D I'm making an app where I have an UIAlertView which I don't
In my iPad app, I have a UIAlertView which pops up upon start up,
I have got an alertview which has a text field UIAlertView* dialog = [[UIAlertView
I already have a custom UIAlertView and in which i want to add UIImageView
I have controller which implements UIAlertViewDelegate. In implementation I have: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
I have a Utils class which shows UIAlertView when certain notifications are triggered. Is
In my app i have reset button which delete all the data of tables
I have two UIAlertView's which are not displayed one after another. Both of the

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.