Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在我的Pin注释上显示标题并使其可单击以执行某些操作?_Iphone_Objective C_Mkmapview - Fatal编程技术网

Iphone 如何在我的Pin注释上显示标题并使其可单击以执行某些操作?

Iphone 如何在我的Pin注释上显示标题并使其可单击以执行某些操作?,iphone,objective-c,mkmapview,Iphone,Objective C,Mkmapview,在我的MapView中,我在某些位置放置了pin,现在我想在这些pin注释上显示一些标题,并使其可单击,以便在单击时可以推送另一个视图。 请帮忙 苹果文档中提供了所有这些问题的答案,我建议您仔细阅读。但是,要进行调用,只需设置title属性 对于按钮等,您需要使用MapView委托方法: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {

在我的MapView中,我在某些位置放置了pin,现在我想在这些pin注释上显示一些标题,并使其可单击,以便在单击时可以推送另一个视图。
请帮忙

苹果文档中提供了所有这些问题的答案,我建议您仔细阅读。但是,要进行调用,只需设置title属性

对于按钮等,您需要使用MapView委托方法:

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

_pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
-(MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
_pin.rightCalloutAccessoryView=[UIButton Button类型:UIButtonTypedTailDisplay];

苹果建议重用注释这是您需要考虑的问题。

这是代码片段:

使用此方法的自定义注释视图

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
    if (annotation == mapView.userLocation) return nil;

    MKPinAnnotationView *pin = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: @"asdf"];
    if (pin == nil)
    {
        pin = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"asdf"] autorelease];
    }
    else
    {
        pin.annotation = annotation;
    }
    pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    pin.pinColor = MKPinAnnotationColorRed;
    pin.animatesDrop = YES;
    [pin setEnabled:YES];
    [pin setCanShowCallout:YES];
    return pin;

}
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{

    //DetailPg=[[BookMarksDetail alloc]initWithNibName:@"BookMarksDetail" bundle:nil];
    //DetailPg.selectRest =[view.annotation title]; //In addition, to get the Title of the AnnotationView.
    //DetailPg.m=1;
    //[self.navigationController pushViewController:DetailPg animated:YES];
    //[DetailPg release];

}