2011-08-23 16 views
8

似たようなスタイルにしたいサンプルのカスタム吹き出しです。私はMKAnnotationから継承することを考えていましたが、開始方法が失われています。コールアウトのデザインをオーバーライドできるかどうかはわかりません。iOS Mapkitカスタム吹き出し

http://1.bp.blogspot.com/_xfo3fwc97Fg/TJ9RZrHVOaI/AAAAAAAAAU4/buhP3q3y0G4/s1600/fmip_locate_20100622.png

内部の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のサブクラスは、ラベルのみを持っています。

+3

参照[この同様の質問](http://stackoverflow.com/questions/5582564/how-do-i-display-a-uipopoverview-as-a-annotation-to-the-map-view-ipad/ 5583505#5583505)。ありがとうございます。 – Anna

+0

私はこれが正確なコピーだと思います。他の投稿の解決策が私が探しているものなら、おそらくこの質問を削除します。 – Bahamut

+0

@Anna Karenina - なぜそれがまだ普通のコールアウトを表示しているのか教えていただけますか?コードを追加しました – Bahamut

答えて

14

は昼寝の数分後に答えを見つけました。ガイドとしてthisを使用して

、私はちょうど注釈コールアウトを示している

-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view 

を上書きする必要がありました。答え、アンナさんにもう一度感謝します。

関連する問題