HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iOS mapView – 只需轻按一下即可拖动图钉大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个带有两个引脚的MapView(自定义引脚). @H_673_5@ @H_673_5@两个引脚都设置为可拖动,但我的问题是在我可以拖动其中一个之前我首先必须选择它才能开始拖动它.这意味着屏幕上有两个水龙头.

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

@H_673_5@谢谢您的帮助!

@H_673_5@
//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语句中: @H_673_5@ @H_673_5@
//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 – 只需轻按一下即可拖动图钉所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。