Tôi đã tạo Tuỳ chỉnh Annotation với sau:chú thích hình ảnh được thay thế bằng RedPushPin khi báo chí dài trên chú thích
-(MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
MKPinAnnotationView *view = nil;
if (annotation != mapView.userLocation)
{
view = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"myAnnotationIdentifier"];
if (!view)
view = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"myAnnotationIdentifier"];
if (((CustomAnnotation *)annotation).annotationType == 1)
{
view.image = [UIImage imageNamed:@"type1.png"];
view.rightCalloutAccessoryView = nil;
view.canShowCallout = YES;
}
else
{
view.image = [UIImage imageNamed:@"type2.png"];
view.rightCalloutAccessoryView = nil;
view.canShowCallout = YES;
}
}
return view;
}
Vấn đề: Khi người dùng bấm và giữ 2 giây trên bất kỳ hình ảnh Chú thích (type1 hoặc type2) , Hình ảnh được thay thế bằng Red PushPin (Mặc định cho iPhone MKPinAnnotationView).
Tôi muốn tránh sự thay thế này. Làm thế nào tôi có thể làm như vậy?
Tôi cũng muốn biết, dù tôi có thể đặt RedPushPin trên MKAnnotationView hay không? – Krishna
Vì bạn đang sử dụng hình ảnh của riêng bạn cho chế độ xem chú thích, bạn nên sử dụng MKAnnotationView. Tuy nhiên, vâng, bạn có thể có một số chú thích là MKAnnotationView và một số là MKPinAnnotationView (không đặt hình ảnh trên những chú thích đó). Sử dụng id sử dụng lại riêng cho từng lớp. – Anna
Cảm ơn Anna .... – Krishna