1
我想在MKMapView上创建自定义标注和标注。我必须创建尺寸更大的注释,并且必须显示三到四行文本(标签)。那么如何创建一个自定义注释和标注泡泡。如何在iphone中创建自定义注释和标注
在此先感谢。
阿希什
我想在MKMapView上创建自定义标注和标注。我必须创建尺寸更大的注释,并且必须显示三到四行文本(标签)。那么如何创建一个自定义注释和标注泡泡。如何在iphone中创建自定义注释和标注
在此先感谢。
阿希什
你应该重新实现只是3种方法:
自定义您的注释使用:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation
这里只是添加子视图,你需要
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
这里只是删除您的自定义来自superview的callOutView
- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
检查这个blog的细节
您可以使用此。
- (MKAnnotationView *)mapView:(MKMapView *)newMapView viewForAnnotation:(id)newAnnotation {
MKAnnotationView *a = [ [ MKAnnotationView alloc ] initWithAnnotation:newAnnotation reuseIdentifier:@"PinView"];
if (a == nil)
a = [ [ MKAnnotationView alloc ] initWithAnnotation:newAnnotation reuseIdentifier: @"PinView" ];
a.image = [ UIImage imageNamed:@"Image.png" ];
a.canShowCallout = YES;
a.rightCalloutAccessoryView = [ UIButton buttonWithType:UIButtonTypeDetailDisclosure ];
UIImageView *imgView = [ [ UIImageView alloc ] initWithImage:[ UIImage imageNamed:@"Image.png" ] ];
a.leftCalloutAccessoryView = imgView;
return a;
}
你能后显示你有什么到目前为止已经试过一些代码? – 2012-05-25 08:48:11
我已经使用了类似于这篇文章中使用的技术:http://stackoverflow.com/questions/2342070/how-to-add-more-details-in-mkannotation-in-ios – brendan