Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

How do I link Xcode map annotations callout to an info page?

  • 18-09-2014 11:26AM
    #1
    Registered Users, Registered Users 2 Posts: 499 ✭✭


    At the moment I am creating a Map with annotations in Xcode. I'm also using Xcode 4 at the moment due to code I copied from an old source.

    Here's a link:
    http://youtu.be/B5RfXxQWjL8
    which I have worked from. In the video at 14:10 he clicks the annotation action button however no callout page pops up.

    I am sure the answer is simple but how do I create an information page and then how do I link each annotation to have a different callout associated action to the information page?

    The guy who made the video also put the source code online which is handy.
    https://www.sendspace.com/file/1unim1

    I may also include below the code so far which actually has minimal changes thus far.

    Code below:

    #import "AnnotationViewController.h"
    #import "Annotation.h"

    @implementation AnnotationViewController
    @synthesize mapView;

    -(void)viewDidLoad {

    [super viewDidLoad];
    [mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];
    [mapView setDelegate:self];


    // Chapel of Isolde
    MKCoordinateRegion ChapelofIsolde = { {0.0, 0.0} , {0.0, 0.0} };
    ChapelofIsolde.center.latitude = 53.3573373;
    ChapelofIsolde.center.longitude = -6.3622526;
    ChapelofIsolde.span.longitudeDelta = 4.02f;
    ChapelofIsolde.span.latitudeDelta = 4.02f;
    [mapView setRegion:ChapelofIsolde animated:YES];

    Annotation *ann1 = [[Annotation alloc] init];
    ann1.title = @Chapel of Isolde;
    ann1.subtitle = @Legen of Tristen & Isolde;
    ann1.coordinate = ChapelofIsolde.center;
    [mapView addAnnotation: ann1];


    // Clonmacnoise
    MKCoordinateRegion Clonmacnoise = { {0.0, 0.0} , {0.0, 0.0} };
    Clonmacnoise.center.latitude = 53.326277;
    Clonmacnoise.center.longitude = -7.986295;
    Clonmacnoise.span.longitudeDelta = 4.02f;
    Clonmacnoise.span.latitudeDelta = 4.02f;
    [mapView setRegion:Clonmacnoise animated:YES];

    Annotation *ann2 = [[Annotation alloc] init];
    ann2.title = @Clonmacnoise;
    ann2.subtitle = @546 AD Monastery;
    ann2.coordinate = Clonmacnoise.center;
    [mapView addAnnotation:ann2];


    //Cloon & Laghtanabba Bog
    MKCoordinateRegion CloonLaghtanabbaBog = { {0.0, 0.0} , {0.0, 0.0} };
    CloonLaghtanabbaBog.center.latitude = 53.537161;
    CloonLaghtanabbaBog.center.longitude = -10.081596;
    CloonLaghtanabbaBog.span.longitudeDelta = 4.02f;
    CloonLaghtanabbaBog.span.latitudeDelta = 4.02f;
    [mapView setRegion:CloonLaghtanabbaBog animated:YES];

    Annotation *ann3 = [[Annotation alloc] init];
    ann3.title = @Cloon & Laghtanabba Bog;
    ann3.subtitle = @National Parks;
    ann3.coordinate = CloonLaghtanabbaBog.center;
    [mapView addAnnotation:ann3];



    }

    -(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
    MKPinAnnotationView *MyPin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation
    reuseIdentifier:@current];
    MyPin.pinColor = MKPinAnnotationColorGreen;

    UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [advertButton addTarget:self action:@selector(button: )


    forControlEvents:UIControlEventTouchUpInside];

    MyPin.rightCalloutAccessoryView = advertButton;
    MyPin.draggable = NO;
    MyPin.highlighted = YES;
    MyPin.animatesDrop=TRUE;
    MyPin.canShowCallout = YES;


    return MyPin;
    }

    -(void)button:(id)sender {

    NSLog(@Button);



    }

    - (void)dealloc
    {
    [super dealloc];
    }

    - (void)didReceiveMemoryWarning
    {
    // If no super view
    [super didReceiveMemoryWarning];

    // Release unused cached images or data.
    }

    #pragma mark - View lifecycle

    /*
    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
    - (void)viewDidLoad
    {
    [super viewDidLoad];
    }
    */

    - (void)viewDidUnload
    {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }

    @end


Advertisement