这是一个示例自定义标注,我希望得到类似的风格.我正在考虑从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
解决方法
原文地址:https://www.jb51.cc/iOS/334883.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。