iOS mapView – 只需轻按一下即可拖动图钉

iOS mapView – 只需轻按一下即可拖动图钉,第1张

概述我有一个带有两个引脚的MapView(自定义引脚). 两个引脚都设置为可拖动,但我的问题是在我可以拖动其中一个之前我首先必须选择它才能开始拖动它.这意味着屏幕上有两个水龙头. 我知道this答案,但他的地图上只有一个针脚,在我看来,一次只能选择一个针脚,所以设置[MyPin setSelected:YES];在这种情况下,我不会帮助我. 谢谢您的帮助! //Custom pin on mapvie 我有一个带有两个引脚的MapVIEw(自定义引脚).

两个引脚都设置为可拖动,但我的问题是在我可以拖动其中一个之前我首先必须选择它才能开始拖动它.这意味着屏幕上有两个水龙头.

我知道this答案,但他的地图上只有一个针脚,在我看来,一次只能选择一个针脚,所以设置[MyPin setSelected:YES];在这种情况下,我不会帮助我.

谢谢您的帮助!

//Custom pin on mapvIEw-(MKAnnotationVIEw *) mapVIEw:(MKMapVIEw *)mapVIEw vIEwForAnnotation:(ID<MKAnnotation>)annotation {            MKAnnotationVIEw *MyPin=[[MKAnnotationVIEw alloc] initWithAnnotation:annotation reuseIDentifIEr:@"current"];             MyPin.draggable = YES;            //Get annotaion Title to determine what image to use            MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc]init];            annotationPoint = annotation;            if([annotationPoint.Title isEqualToString:@"user"])            {                MyPin.image = [UIImage imagenamed:@"userLocation_pin"];                MyPin.centerOffset = CGPointMake(-13,-5); //Offset custom image to display at the exact pin point GPointMake([left/right],[up/down]);            }            else if ([annotationPoint.Title isEqualToString:@"destination"])            {                MyPin.image = [UIImage imagenamed:@"destination_pin_up"];                MyPin.centerOffset = CGPointMake(-13,[up/down]);            }            return MyPin;        }
解决方法 通过添加[MyPin setSelected:YES]来管理解决我自己的问题;在这样的if语句中:

//Custom pin on mapvIEw-(MKAnnotationVIEw *) mapVIEw:(MKMapVIEw *)mapVIEw vIEwForAnnotation:(ID<MKAnnotation>)annotation {            MKAnnotationVIEw *MyPin=[[MKAnnotationVIEw alloc] initWithAnnotation:annotation reuseIDentifIEr:@"current"];             MyPin.draggable = YES;            //Get annotaion Title to determine what image to use            MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc]init];            annotationPoint = annotation;            if([annotationPoint.Title isEqualToString:@"user"])            {                MyPin.image = [UIImage imagenamed:@"userLocation_pin"];                MyPin.centerOffset = CGPointMake(-13,[up/down]);                [MyPin setSelected:YES];            }            else if ([annotationPoint.Title isEqualToString:@"destination"])            {                MyPin.image = [UIImage imagenamed:@"destination_pin_up"];                MyPin.centerOffset = CGPointMake(-13,[up/down]);                [MyPin setSelected:YES];            }            return MyPin;        }
总结

以上是内存溢出为你收集整理的iOS mapView – 只需轻按一下即可拖动图钉全部内容,希望文章能够帮你解决iOS mapView – 只需轻按一下即可拖动图钉所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1020938.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存