2011-08-05 12 views
1

私はマップキットとasp.netのWebサービスを使ってアプリケーションを開発するタスクを持っています。iphoneでダイナミックな地図のピンポップアップメッセージを取得する方法

私の問題は、Webサービスから場所を取得したときです。そしてその場所に応じて、ピンはその場所にも設定されています。

しかし、私の問題は、ピンのポップアップを与えたことです。ユーザーがピンをクリックするとポップアップが表示されます。ピンのポップアップは機能しません。私は、ピンとピンのポップアップに関連するすべてのコードを含んでいます。そのピンをクリックしても機能しません。

また、私が与えた地図とメッセージにピンを表示するコードも追加しています。そのために

- (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; 
     } 


    } 
} 
+0

については、以下のコードを実装する必要があります。 'lines'とは何ですか?' i'変数はどのように設定されていますか? – Anna

+0

Ok liines(NSArray)はここから格納されます。xmlの文字からsoapResultを取得しています。 NSLog(@ "SoapString:%@"、soapResult); str = [NSString stringWithString:soapResult]; NSCharacterSet * spacenotwant = [NSCharacterSet characterSetWithCharactersInString:@ ""]; str = [[str componentsSeparatedByCharactersInSet:spacesenotwant] componentsJoinedByString:@ "、"]; lines = [str componentsSeparatedByString:@ "、"]; xml取得値を増やして格納するためのdidStart(XML Parser)要素から設定されたi(int) –

答えて

0

uがcalloutAccessoryControlTappedのコードがやろうとしているかを説明してくださいその

- (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]; 
      } 

    } 
} 
関連する問題