我使用下面的代码将所有联系人显示为注释地图here,现在我有一个问题是有什么方法可以在地图上获取某些操作的选定联系人(注释)(例如,呼叫,消息,... 。)
//add each object in Contacts entity to map view
NSManagedObjectContext *context = [self managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Contacts" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:nil];
for (info in fetchedObjects) {
NSLog(@"Name: %@", [info valueForKey:@"name"]);
//initializetion latitude and longitude
aLng=[[info valueForKey:@"lng"] doubleValue];
aLat=[[info valueForKey:@"lat"] doubleValue];
//if latitude and longitude not null
if(aLng && aLat && aLng!=0.0 &&aLat!=0.0)
{
//create a new Coordinate
CLLocationCoordinate2D wimLocation;
wimLocation.latitude=aLat;
wimLocation.longitude=aLng;
//create a new Annotation and initializetion it
MKPointAnnotation * myAnnotation=[MKPointAnnotation alloc];
myAnnotation.coordinate=wimLocation;
myAnnotation.title=[info valueForKey:@"name"];
//add create Annotation to mapview
[self.mapview addAnnotation:myAnnotation];
}
}
请根据我的代码提出您的答案,谢谢