MKMapView->显示我的位置按钮
我有一个用这些源代码行实现的 MKMapView
(我的位置是蓝色子弹,另一个是紫色图钉):
- (MKAnnotationView *)mapView:(MKMapView *)mapViewLocal viewForAnnotation:(id <MKAnnotation>)annotation {
if (annotation == mapViewLocal.userLocation) {
mapViewLocal.userLocation.title = @"Test";
[mapViewLocal setRegion:MKCoordinateRegionMakeWithDistance(mapViewLocal.userLocation.coordinate, 1000, 1000) animated:YES];
return nil;
}
MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapViewLocal dequeueReusableAnnotationViewWithIdentifier:@"Pin"];
if(pinView == nil) {
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"] autorelease];
pinView.pinColor = MKPinAnnotationColorPurple;
pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.animatesDrop = NO;
pinView.canShowCallout = YES;
} else {
pinView.annotation = annotation;
}
return pinView;
}
紫色图钉有一个详细信息披露按钮,但我的注释没有。如何设置这样的按钮?
这就是我可以在按下按钮时执行某些操作的方法:
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
我如何区分我的位置和所有其他位置,因为我需要不同的处理。是否有另一个代表或者我必须制定某种 if 子句?
I have a MKMapView
implemented with these lines of source code (my location is a blue bullet, the other one's are purple pins):
- (MKAnnotationView *)mapView:(MKMapView *)mapViewLocal viewForAnnotation:(id <MKAnnotation>)annotation {
if (annotation == mapViewLocal.userLocation) {
mapViewLocal.userLocation.title = @"Test";
[mapViewLocal setRegion:MKCoordinateRegionMakeWithDistance(mapViewLocal.userLocation.coordinate, 1000, 1000) animated:YES];
return nil;
}
MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapViewLocal dequeueReusableAnnotationViewWithIdentifier:@"Pin"];
if(pinView == nil) {
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"] autorelease];
pinView.pinColor = MKPinAnnotationColorPurple;
pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.animatesDrop = NO;
pinView.canShowCallout = YES;
} else {
pinView.annotation = annotation;
}
return pinView;
}
The purple pins have a detail disclosure button, but my annotation does not have one. How can I set such a button?
And that is the method where I can do somethin a button is pressd:
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
How could I differentiate between my location and all other one's, because I need a different handling. Is there another delegate or do I have to make some kind of if clause?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在你的
didUpdateToLocation
中写一些类似东西
的
in your
didUpdateToLocation
write something likeAnd Then
Something Like