iOS Mapkit自定义标注

iOS Mapkit自定义标注,第1张

概述这是一个示例自定义标注,我希望得到类似的风格.我正在考虑从MKAnnotation继承,但我失去了如何启动它,我不知道标注的设计是否可以被覆盖. 有关如何使用ui控件实现此自定义标注的任何想法? 编辑:这是我的代码来自类似的StackOverflow答案: - (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(i 这是一个示例自定义标注,我希望得到类似的风格.我正在考虑从MKAnnotation继承,但我失去了如何启动它,我不知道标注的设计是否可以被覆盖.

有关如何使用ui控件实现此自定义标注的任何想法?

编辑:这是我的代码来自类似的StackOverflow答案:

- (MKAnnotationVIEw *)mapVIEw:(MKMapVIEw *)mapvIEw vIEwForAnnotation:(ID <MKAnnotation>)annotation{    if ([annotation isKindOfClass:[MKUserLocation class]])        return nil;    static Nsstring* AnnotationIDentifIEr = @"AnnotationIDentifIEr";    MKAnnotationVIEw *annotationVIEw = [mapVIEw dequeueReusableAnnotationVIEwWithIDentifIEr:AnnotationIDentifIEr];    if(annotationVIEw)        return annotationVIEw;    else    {        UIImage *img = [UIImage imagenamed:@"default_thumb.png"];        MKAnnotationVIEw *annotationVIEw =             [[MKAnnotationVIEw alloc] initWithAnnotation:annotation reuseIDentifIEr:AnnotationIDentifIEr];        annotationVIEw.canShowCallout = YES;        annotationVIEw.image = img;        annotationVIEw.draggable = YES;        /*        // change left accessory vIEw button with image        UIImageVIEw *leftAccVIEw = [[UIImageVIEw alloc] initWithImage:img];        annotationVIEw.leftCalloutAccessoryVIEw = leftAccVIEw;        //include a right button to show more info                 UIbutton* rightbutton = [UIbutton buttonWithType:UIbuttonTypeDetaildisclosure];        [rightbutton addTarget:self action:@selector(calloutSubMenu:) forControlEvents:UIControlEventtouchUpInsIDe];        [rightbutton setTitle:annotation.Title forState:UIControlStatenormal];        annotationVIEw.rightCalloutAccessoryVIEw = rightbutton;                  */        return annotationVIEw;    }    return nil;}// Customize accessory vIEw- (voID)mapVIEw:(MKMapVIEw *)mapvIEw annotationVIEw:(MKAnnotationVIEw *)vIEw calloutAccessoryControlTapped:(UIControl *)control{    [mapvIEw deselectAnnotation:vIEw.annotation animated:YES];    PopOverCallout *popOverCallout = [[PopOverCallout alloc]init];    UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentVIEwController:popOverCallout];    self.annotationPopoverController = popOver;    popOver.popoverContentSize = CGSizeMake(500,500);    [popOver presentPopoverFromrect:vIEw.bounds inVIEw:vIEw permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];    }

(voID)mapVIEw:(MKMapVIEw *)mapvIEw annotationVIEw:(MKAnnotationVIEw *)vIEw calloutAccessoryControlTapped:(UIControl *)control

触摸引脚时应该调用以显示标注权限吗?但是会发生一个空白的常规标注.我可能做错了什么?

顺便说一句:UIVIEwController子类只在它的XIB上有一个标签,几乎是空白的.

解决方法 午睡几分钟后找到答案.

使用this作为指南,我只需要覆盖

-(voID)mapVIEw:(MKMapVIEw *)mapVIEw dIDSelectAnnotationVIEw:(MKAnnotationVIEw *)vIEw

它显示了注释标注.再次感谢安娜女士的回答.

总结

以上是内存溢出为你收集整理的iOS Mapkit自定义标注全部内容,希望文章能够帮你解决iOS Mapkit自定义标注所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存