我有一个地图和一组注释,每个都有一个'父'属性.目前,当我添加注释时,我实现了didAddAnnotationViews方法来为这些注释设置动画,使它们看起来像是来自父级的坐标.在删除注释期间有没有办法做到这一点?当我从地图中删除注释时,我希望它为其父坐标设置动画,据我所知,当删除注释时,didAddAnnotationViews没有等效物.
我正在尝试自动显示注释标题,而不是在点击时显示它.我使用下面的代码来显示注释并使其在地图上居中.
self.ann.setCoordinate(currentLocation2D)
self.ann.title = "Title"
self.ann.subtitle = "Subtitle"
self.mapView.addAnnotation(self.ann);
self.span = MKCoordinateSpanMake(0.005, 0.005)
self.region = MKCoordinateRegion(center: currentLocation2D, span: self.span)
self.mapView.setRegion(self.region, animated: true)
Run Code Online (Sandbox Code Playgroud)
我能看到的title,subtitle而CalloutAccessoryView当我点击的注解,但是可能无法自动显示.
我正在编写一个应用程序iOS 7.0+,我想使用新功能imageWithRenderingMode.我有一个使用此代码的地图注释:
-(MKAnnotationView*)annotationView {
MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:self reuseIdentifier:@"AnnotationIdentifier"];
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.image = [[UIImage imageNamed:@"star"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.tintColor = [UIColor redColor];
return annotationView;
}
Run Code Online (Sandbox Code Playgroud)
我原本以为我的针脚是红色的,但是保持黑色,只有标注(i)图标变成红色.

我试图设置self.view.tintColor和self.mapView.tintColor我的,ViewController但这也不起作用.如何将此引脚变为红色?
在我的iPad应用程序上,我使用iOS地图使用注释显示几个点.我想在选择注释时显示自定义标注.我正在使用UIPopoverController来显示callout.但是,这仅在第一次点击注释时有效.如果我想在相同的注释上看到标注,我必须先选择不同的注释,然后点击之前的注释.
基本上这个委托方法不是第二次触发.
-(void)mapView:(MKMapView *)mapView
didSelectAnnotationView:(MKAnnotationView *)view
Run Code Online (Sandbox Code Playgroud)
我正在使用故事板,并在那里设置委托.这就是我设置注释的方式.
[self.mapView addAnnotations:self.placemarksArray]
Run Code Online (Sandbox Code Playgroud)
谁能告诉我上述问题的原因?谢谢
我有一个有很多注释的mapview,其中大多数都非常接近.我想要做的是类似于iOS上的Photo应用程序,当它们彼此太靠近时,注释被分组,每当你缩小时,如果注释距离太远,它们就会被分组.
我已经看过这个问题,但给出的答案并不是我真正想要的.
我正在寻找可以自己实现的库或算法.
我把个人形象改为传统的红色别针.当我打开地图以显示图钉时,图像会覆盖整个地图.是否有最大尺寸的引脚图像或如何在代码中集成某些东西以适应尺寸标准的经典引脚?
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
return nil
}
let annotationIdentifier = "SomeCustomIdentifier" // use something unique that functionally identifies the type of pin
var annotationView: MKAnnotationView! = mapView.dequeueReusableAnnotationViewWithIdentifier(annotationIdentifier)
if annotationView != nil {
annotationView.annotation = annotation
} else {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
annotationView.image = UIImage(named: "pin maps.png")
annotationView.canShowCallout = true
annotationView.calloutOffset = CGPointMake(-8, 0)
annotationView.autoresizesSubviews = true
annotationView.rightCalloutAccessoryView = UIButton(type: UIButtonType.DetailDisclosure) as UIView
}
return annotationView
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个注释,我将其添加到MKMapView中.如何使用自定义图像而不是标准红色针?
@interface AddressAnnotation : NSObject<MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
MKPinAnnotationColor pinColor;
}
@property (nonatomic,retain) NSString *title;
@property (nonatomic,retain) NSString *subtitle;
@property (nonatomic, assign) MKPinAnnotationColor pinColor;
@end
Run Code Online (Sandbox Code Playgroud) 我刚刚进入Obj C,我正在寻找创建一个MKAnnotations数组.
我已经创建了一个名为MKAnnotation的类TruckLocation,它包含名称,描述,纬度和经度.
这是我到目前为止的数组:
NSMutableArray* trucksArray =[NSMutableArray arrayWithObjects: @[<#objects, ...#>] nil];
Run Code Online (Sandbox Code Playgroud) 在我的iphone应用程序中,我使用MapKit和MKMapView以及自定义MKAnnotationView.
问题是当注释在地图上重叠时(在我的应用中,注释是照片而这些照片可能重叠),当你点击前面出现的注释时,它是另一个注释(在背面)接收事件(似乎是随机的) ).
我没有找到任何方法将事件发送到前端注释.我不敢相信这个bug /问题没有任何解决方案!
stackoverflow上的Z排序和重叠注释问题的顺序对我没有多大帮助.
欢迎任何想法(即使是肮脏的解决方案)!
这是我的一些代码(没什么特别的,很常见):
CustomAnnotation.h
@interface CustomAnnotation : NSObject <MKAnnotation> {
@private
CustomAnnotationView* view;
}
@property (nonatomic, retain) CustomAnnotationView* view;
@end
Run Code Online (Sandbox Code Playgroud)
CustomAnnotation.m
@implementation CustomAnnotation
@synthetize view;
Run Code Online (Sandbox Code Playgroud)
CustomAnnotationView.h
@interface CustomAnnotationView : MKAnnotationView {
}
@end
Run Code Online (Sandbox Code Playgroud)
CustomAnnotationView.m
@implementation CustomAnnotationView
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
// Do something related to the annotation tapped
}
@end
Run Code Online (Sandbox Code Playgroud)
主类... //添加了注释,其中一些与其他注释重叠.
- (void)addAnnotation:(CustomAnnotation*)annotation {
[map addAnnotation:annotation];
}
...
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
NSString* identifier …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有自定义注释,其中leftCalloutAccessoryView是圆形UIView.这在代码中完美地在模拟器中工作:
let rideTimeView = UIView()
rideTimeView.frame = CGRectMake(5, 5, 50, 50)
rideTimeView.layer.cornerRadius = 25
Run Code Online (Sandbox Code Playgroud)
当我在实际设备上运行应用程序时出现问题.它在(我相信)6和6 Plus上工作正常,但在4和5的底部重叠.
有什么办法可以得到注释的尺寸吗?
mkannotation ×10
ios ×7
mkmapview ×5
objective-c ×5
mapkit ×4
swift ×2
iphone ×1
swift2 ×1
uiimageview ×1
xcode7 ×1