我removeAnnotations用来删除我的注释,mapView但同样删除用户位置ann.我该如何防止这种情况,或者如何让用户回来查看?
NSArray *annotationsOnMap = mapView.annotations;
[mapView removeAnnotations:annotationsOnMap];
Run Code Online (Sandbox Code Playgroud) 我有一个UITableView,每个单元格都包含一个Map按钮.当我点击每个按钮时,会显示地图视图并添加相应的注释引脚.
点击每个地图按钮时会调用此代码,
double tempLatitude = [[[myDict objectForKey:key] objectAtIndex:15] doubleValue];
double tempLongitude = [[[myDict objectForKey:key] objectAtIndex:16] doubleValue];
// key is the cell index.
//--** Setting the Latitude and Longitude
CLLocationCoordinate2D myCoordinate;
myCoordinate.latitude = tempLatitude;
myCoordinate.longitude = tempLongitude;
MyMapAnnotation *MyAnnotation = [[[MyMapAnnotation alloc] initWithCoordinate:myCoordinate addressDictionary:nil]autorelease];
MyAnnotation.title = [[myDict objectForKey:key] objectAtIndex:1];
MyAnnotation.subtitle = [NSString stringWithFormat:@"%f %f", MyAnnotation.coordinate.latitude, MyAnnotation.coordinate.longitude];
Run Code Online (Sandbox Code Playgroud)
这是MyMapAnnotation的代码,
@synthesize coordinate = theCoordinate;
@synthesize title = theTitleAnnotation;
@synthesize subtitle = theSubTitleAnnotation;
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary
{
if ((self = [super initWithCoordinate:coordinate addressDictionary:addressDictionary]))
{ …Run Code Online (Sandbox Code Playgroud) mkmapview ×2
annotations ×1
ios ×1
iphone ×1
mapkit ×1
mkannotation ×1
objective-c ×1
userlocation ×1
xcode ×1