如何在iphone地图套件中获取pin弹出消息

如何在iphone地图套件中获取pin弹出消息,iphone,mkmapview,Iphone,Mkmapview,我的任务是使用asp.net的地图工具包和web服务开发应用程序 我的问题是当我从web服务获取位置时。根据这个位置,销也被设置到它的位置 但我的问题是,我已经在上面弹出了pin。当用户点击pin时,它将显示弹出窗口。但是别针上的弹出窗口不起作用。我已经包括了pin和pin弹出窗口的所有相关代码。但当我点击那个别针时,它就不起作用了 我还添加了代码,以便在地图上显示pin和我给出的消息 - (MKAnnotationView *)mapView:(MKMapView *)map viewForA

我的任务是使用asp.net的地图工具包和web服务开发应用程序

我的问题是当我从web服务获取位置时。根据这个位置,销也被设置到它的位置

但我的问题是,我已经在上面弹出了pin。当用户点击pin时,它将显示弹出窗口。但是别针上的弹出窗口不起作用。我已经包括了pin和pin弹出窗口的所有相关代码。但当我点击那个别针时,它就不起作用了

我还添加了代码,以便在地图上显示pin和我给出的消息

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
    NSLog(@"Controll comes here");

    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.userInteractionEnabled = YES;
    UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    [disclosureButton setFrame:CGRectMake(0, 0, 30, 30)];

    pin.rightCalloutAccessoryView = disclosureButton;
    pin.pinColor = MKPinAnnotationColorRed;
    pin.animatesDrop = YES;
    [pin setEnabled:YES];
    [pin setCanShowCallout:YES];
    return pin;

}

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
    NSString *strTitle = [NSString stringWithFormat:@"%@",[lines objectAtIndex:i]];
    NSMutableDictionary *d;
    NSMutableArray *temp=[NSArray arrayWithArray:lat];

    //  NSArray *temp=[NSArray arrayWithArray:[NSArray arrayWithArray:[reports objectAtIndex:0]]];
    for (int k = 0; k< i -1; k++)
    {
        d = (NSMutableDictionary*)[temp objectAtIndex:k];
        NSString *strAddress = [NSString stringWithFormat:@"%@",[d valueForKey:@"comments"]];

        if([strAddress isEqualToString:strTitle]) {
            [self presentModalViewController:self.nxtDetailsVCtr animated:YES];
            [self.nxtDetailsVCtr.lblDetail setText:strAddress];     
            break;
        }


    }
}

为此,你需要实现下面的代码

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
    NSString *strTitle = [NSString stringWithFormat:@"%@",[view.annotation title]];
    NSMutableDictionary *d;
    NSArray *temp=[NSArray arrayWithArray:[NSArray arrayWithArray:[reports objectAtIndex:0]]];
    for (int i = 0; i<[temp count]; i++)
    {
        d = (NSMutableDictionary*)[temp objectAtIndex:i];
        NSString *strAddress = [NSString stringWithFormat:@"%@",[d valueForKey:@"comments"]];

            if([strAddress isEqualToString:strTitle])
            {
                if(!nxtDetails){
                   nxtDetails=[[MyCityDetails alloc] initWithNibName:@"MyCityDetails" bundle:nil];
                }
                NSLog(@"%@",[dForAnnotation valueForKey:@"report_types"]);
                nxtDetails.dForAnnotation= dForAnnotation;
nxtDetails.arForAnnotation=d;
                [self.navigationController pushViewController:nxtDetails animated:YES];
            }

    }
}

请解释Callout AccessoryControlTapped中的代码试图执行的操作。什么是行,i变量是如何设置的?好的,从这里存储liinessnarray,我从xml找到的字符中得到soapResult。NSLog@SoapString:%@,soapResult;str=[nsstringwithstring:soapResult];NSCharacterSet*spacenotwant=[NSCharacterSet characterSetWithCharactersInString:@];str=[[str componentsSeparatedByCharactersInSet:spacenotwant]componentsjoinedbythring:@,];行=[str componentsSeparatedByString:@,];和didStart XML Parser元素中的iintset,用于增加XML get值并存储它。