Iphone 显示问题的注释

Iphone 显示问题的注释,iphone,ios,objective-c,mkmapview,mapkit,Iphone,Ios,Objective C,Mkmapview,Mapkit,我创建了一个带有图钉的MKMapView 当我按下pin键时,我会看到标题和副标题,但我希望看到它而不点击。 所以,我希望标题和副标题在地图显示后立即出现 这是我的密码: self.mapView = [[[MKMapView alloc]init] autorelease]; mapView.frame = self.view.bounds; mapView.delegate = self; [self.view addSubview:mapView];

我创建了一个带有图钉的MKMapView

当我按下pin键时,我会看到标题和副标题,但我希望看到它而不点击。 所以,我希望标题和副标题在地图显示后立即出现

这是我的密码:

    self.mapView = [[[MKMapView alloc]init] autorelease];
    mapView.frame = self.view.bounds;
    mapView.delegate = self;
    [self.view addSubview:mapView];

    location = CLLocationCoordinate2DMake(lattitude, longitude);



    MKCoordinateRegion region = self.mapView.region;
    region.center = location;
    region.span.longitudeDelta = kSpan;
    region.span.latitudeDelta = kSpan;
    [self.mapView setRegion:region animated:YES];

    CustomMapAnnotation *newAnnotation = [[CustomMapAnnotation alloc] init];
    newAnnotation.title = @"Title";
    newAnnotation.subtitle = @"Subtitle";
    newAnnotation.accessibilityTraits = UIAccessibilityTraitButton;

    newAnnotation.coordinate = location;
    annotation = newAnnotation;
    [mapView addAnnotation:annotation];
    [newAnnotation release];

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotationDel
{

    MKPinAnnotationView *pinView = nil;

    static NSString *defaultPinID = @"mapPin";

    pinView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];

    if (pinView == nil)
        pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotationDel reuseIdentifier:defaultPinID] autorelease];

    pinView.pinColor = MKPinAnnotationColorRed;
    pinView.canShowCallout = YES;
    pinView.animatesDrop = YES;
    [pinView setSelected:YES];

    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton addTarget:self action:@selector(detailButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    pinView.rightCalloutAccessoryView = rightButton;

    return pinView;

}
self.mapView=[[MKMapView alloc]init]autorelease];
mapView.frame=self.view.bounds;
mapView.delegate=self;
[self.view addSubview:mapView];
位置=CLLocationCoordination2dMake(纬度、经度);
MKCoordinateRegion region=self.mapView.region;
region.center=位置;
region.span.longitudeDelta=kSpan;
region.span.latitudeDelta=kSpan;
[self.mapView setRegion:区域动画:是];
CustomMapAnnotation*newAnnotation=[[CustomMapAnnotation alloc]init];
newAnnotation.title=@“title”;
newAnnotation.subtitle=@“subtitle”;
newAnnotation.accessibilityTraits=UIAccessibilityTraitButton;
newAnnotation.coordinate=位置;
注释=新注释;
[地图视图添加注释:注释];
[新注释发布];
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图用于注释:(id)annotationDel
{
MKPinAnnotationView*pinView=nil;
静态NSString*defaultPinID=@“mapPin”;
pinView=(MKPinAnnotationView*)[self.mapView出列可重用AnnotationViewWithIdentifier:defaultPinID];
如果(pinView==nil)
pinView=[[MKPinAnnotationView alloc]initWithAnnotation:annotationDel重用标识符:defaultPinID]自动释放];
pinView.pinColor=MKPinAnnotationColorRed;
pinView.canShowCallout=是;
pinView.animatesDrop=是;
[选择的pinView设置:是];
UIButton*rightButton=[UIButton Button类型:UIButtonTypedTailButton];
[rightButton添加目标:自我操作:@选择器(DetailButton按下:)用于控制事件:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView=rightButton;
返回pinView;
}

使用
MKMapView的
selectAnnotation:animated
方法

[mapView selectAnnotation:YorAnnotation animated:YES];

有关更多信息,请阅读并提问。

您是否尝试在viewdidload方法中调用viewForAnnotation?pin出现后?Patel回答正确