Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selectAnnotation method of Mapview doesn't work for iOS7

I am working with an application for iPhone in which I need to show the POIs pins for different locations. I need to show the callout popped up by default on first POI. I have managed to do so for iOS6 but facing problem in iOS7. I am writing my code below, it is working well with iOS6 but not on iOS7. It's not showing any error but for iOS7, I am not able to callout the popup on map POI by default.

Here is my code part :

DDAnnotation *annotation2 = [[DDAnnotation alloc] initWithCoordinate:coordinates addressDictionary:nil] ;
        annotation2.title = [[arrPOIs objectAtIndex:0] objectForKey:@"Name"];
        annotation2.subtitle = [[arrPOIs objectAtIndex:0] objectForKey:@"AmbassadorTagline"];
        annotation2.dictionaryData = [arrPOIs objectAtIndex:0];
        annotation2.strCountNumber = [NSString stringWithFormat:@"1"];

[mapView selectAnnotation:annotation2 animated:YES];
        [annotation2 release];
        annotation2 = nil;

Please gude me if you have any ideas/suggestions for this.

like image 510
user2897266 Avatar asked Jan 25 '26 18:01

user2897266


1 Answers

I used this code for ios7 and it's good

first

#import <MapKit/MapKit.h>

then in

ViewDidLoad

add this code

CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = someLocation;
annotationCoord.longitude = someLocation;
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
annotationPoint.coordinate = annotationCoord;
annotationPoint.title = @"YourTitle";
annotationPoint.subtitle = @"YourSubtitle";
[map addAnnotation:annotationPoint];
like image 171
Abdullah Alhattami Avatar answered Jan 28 '26 21:01

Abdullah Alhattami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!