8
似たようなスタイルにしたいサンプルのカスタム吹き出しです。私はMKAnnotationから継承することを考えていましたが、開始方法が失われています。コールアウトのデザインをオーバーライドできるかどうかはわかりません。iOS Mapkitカスタム吹き出し
内部の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
が呼ばれるべき?何も起こらないのは、空白の通常のコールアウトが表示されることです。何が間違っているのでしょうか?
はところで:それはXIBだとかなりのブランクで上のUIViewControllerのサブクラスは、ラベルのみを持っています。
参照[この同様の質問](http://stackoverflow.com/questions/5582564/how-do-i-display-a-uipopoverview-as-a-annotation-to-the-map-view-ipad/ 5583505#5583505)。ありがとうございます。 – Anna
私はこれが正確なコピーだと思います。他の投稿の解決策が私が探しているものなら、おそらくこの質問を削除します。 – Bahamut
@Anna Karenina - なぜそれがまだ普通のコールアウトを表示しているのか教えていただけますか?コードを追加しました – Bahamut