如何在iPhone中的地图套件动态中获取pin弹出消息
我的任务是使用地图套件和 asp.net 的 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;
}
}
}
I have a task to develop the application with map kit and web service of asp.net.
My problem is when I got the location from the web service. And according that location the pin is also setting to it's located place.
But my problem is I have given the pin pop up on it. it is working when the user click on the pin it will show the pop up. but the pop up on the pin is not working. I have included all related code for the pin and pin pop up. but it is not working when I am clicking on that pin.
I am also adding the code to display the pin on map and message which I have given.
- (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;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您需要为此实现以下代码
For that u need to implement the below code for that