2016-05-18 4 views
0

私は現在、同じビジネスではなく同じデザインの「Uber様」アプリケーションを構築しています。「ピックアップ位置の設定」ビュー/ボタンを表現するにはどうすればよいか知りたいと思います。カスタム注釈コールアウトビューまたはカスタムビュー?

私はすでに、この記事を見た:それはカスタム吹き出しビューのように見えたが、今では少し違う、と私はどこ場合を開始するために理解していない古いバージョンでは、カスタム注釈吹き出しの表示について

Customize MKAnnotation Callout View?私は同じ結果を持つようにしたい:あなたの助けのための

enter image description here

感謝を!

答えて

1

左のアクセサリと右のアクセサリに異なる画像を設定するには、このコードを使用します。その後

// set different pins colors 
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { 
MKAnnotationView *annotationView = nil; 
if([annotation isKindOfClass:[YOURANNOTATION class] ]) 
{ 
    static NSString * AnnotationID = @"YOURANNOTATION"; 
    annotationView = [self.mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationID]; 
    if(annotationView == nil) 
    { 
     annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation 
                 reuseIdentifier:AnnotationID] ; 

    } 
    UIImage * flagImage = nil; 

      flagImage = [UIImage imageNamed:@"[email protected]"]; 
      [annotationView setImage:flagImage]; 
      annotationView.canShowCallout = YES; 

      // add an image to the callout window 
      UIImageView *leftIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]]; 
      annotationView.leftCalloutAccessoryView = leftIconView; 


    //adding right button accessory 
    UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 

    annotationView.rightCalloutAccessoryView = infoButton; 

    //image size and adding image on left accessory 
    CGRect resizeRect; 
    resizeRect.size = flagImage.size; 
    resizeRect.origin = (CGPoint){0.0f, 0.0f}; 
    UIGraphicsBeginImageContext(resizeRect.size); 
    [flagImage drawInRect:resizeRect]; 
    UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext();  
    annotationView.image = resizedImage; 

} 
return annotationView; 

} 

選択した注釈

私はそれに迅速にそれを試してみるよ
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 
{ 


YOURANNOTATION *annotation=(YOURANNOTATION*)view.annotation; 

//do something with your annotation 

} 
+0

感謝を呼び出すが、私の質問は以上であったために、彼らはカスタム注釈ビューまたは単にカスタムビューを使用しましたか? :) –

+0

これはカスタムビューで、アノテーションビューに配置している可能性があります。アノテーションのカスタム・ビューを追加してみてください。 – Santo

関連する問題