1
我有一個任務,開發與asp.net的地圖工具包和web服務的應用程序。如何在地圖工具箱中獲取pin彈出消息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;
}
}
}
請解釋什麼calloutAccessoryControlTapped代碼試圖做的。 '線'是什麼,'i'變量是如何設置的? – Anna
好的liines(NSArray)將會從這裏存儲,我從XML找到的字符得到soapResult。的NSLog(@ 「SoapString:%@」,soapResult); str = [NSString stringWithString:soapResult]; NSCharacterSet * spacenotwant = [NSCharacterSet characterSetWithCharactersInString:@「」]; str = [[str componentsSeparatedByCharactersInSet:spacenotwant] componentsJoinedByString:@「,」]; lines = [str componentsSeparatedByString:@「,」];我從didStart(XML Parser)元素中設置i(int),用於增加xml獲取值並存儲它.Got IT。 –