iOS Mapkit自定义标注
这里有一个样本自定义标注,我想要得到一个类似的风格。 我正在考虑从MKAnnotationinheritance,但我迷失了如何启动它,我不知道标注的devise是否可以被覆盖。
任何想法如何实现这个自定义标注与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和非常空白。
睡了几分钟后find答案。
以此为指导,我只需要重写
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
其中显示了注释标注。 安娜女士再次感谢你的回答。