【发布时间】:2010-05-07 08:54:39
【问题描述】:
每当我们加载地图视图时,它都会自动显示当前用户的位置。在我的情况下,我在地图上显示另一个位置,这样地图会加载当前位置并缩放到我给出的位置..但是,当前位置点没有显示(自动出现的蓝色位置..)。 我给了 mapView.showCurrentLocation=TRUE;但它没有显示。 所以任何人都可以告诉它的工作方式,它应该说当前位置标记,然后缩放到我给出的点。 谢谢
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString *defaultPinID = @"CameraAnnotation";
MKPinAnnotationView *retval = nil;
static int postag=1;
(MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if(annotation=MapView.userLocation)
{
return nil;
}
// If we have to, create a new view
else if (retval == nil)
{
retval = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
UIButton *myDetailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
myDetailButton.frame = CGRectMake(0, 0, 50, 23);
myDetailButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
myDetailButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
myDetailButton.tag=postag;
postag++;
[myDetailButton addTarget:self action:@selector(showLinks:) forControlEvents:UIControlEventTouchUpInside];
retval.rightCalloutAccessoryView = myDetailButton;
[retval setPinColor:MKPinAnnotationColorRed];
retval.animatesDrop = YES;
retval.canShowCallout = YES;
}
return retval;
}
【问题讨论】:
-
您是在签入模拟器还是设备?
标签: iphone cocoa-touch mapkit