2017-05-16 6 views
1

私のcalloutAccessoryControllerTappedに問題があります。分かり次第、私はコールアウト内に2つのボタンを持っています - それぞれは、私のマップビューでモーダルポップアップにセグメンテーションします。分で私のsegueは動作しますが、両方のボタンが同じポップアップに繋がります。私はボタンとそのセグを区別できる必要があります。Mapbox - calloutAccessoryControllerTapped

これは可能ですか?しかし、このタイプのエラー「値を考え出すされた 『UIViewの』私はこの質問をGoogleで検索していると多くの答えが

if (control == view.leftCalloutAccessoryView) { 

の下のコード行を使用することをお勧めしているように見える何のメンバーを持っていない 『leftCalloutAccessoryView』。私は本当にだろう誰かがこの問題で私を助けることができれば感謝し、私ははっきりと問題を説明していない場合は謝罪、私はそう私の最高の程度まで行われてきた以下

は私のコードです:シンプル

func mapView(_ mapView: MGLMapView, annotationCanShowCallout annotation: MGLAnnotation) -> Bool { 

    return true 


} 


func mapView(_ mapView: MGLMapView, annotation: MGLAnnotation, calloutAccessoryControlTapped control: UIControl) { 


    self.performSegue(withIdentifier: "Show", sender: view) 

} 

func mapView(_ mapView: MGLMapView, rightCalloutAccessoryViewFor annotation: MGLAnnotation) -> UIView? { 

    guard let skateAnnotation = annotation as? SkateAnnotation else { return nil } 

    if skateAnnotation.canEdit { 
     return UIButton(type: .detailDisclosure) 
    } 

    return nil 


} 

func mapView(_ mapView: MGLMapView, leftCalloutAccessoryViewFor annotation: MGLAnnotation) -> UIView? { 

    return UIButton(type: .contactAdd) 


} 



func mapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? { 

    return nil 

} 


} 

答えて

0

何か(変更コード必要に応じてあなた自身の要件に合わせて)これは左右の吹き出しアクセサリコントロールを区別するために機能します。

func mapView(_ mapView: MGLMapView, leftCalloutAccessoryViewFor annotation: MGLAnnotation) -> UIView? { 
    let button = UIButton(type: .detailDisclosure) 
    button.tag = 100 
    return button 
} 

func mapView(_ mapView: MGLMapView, rightCalloutAccessoryViewFor annotation: MGLAnnotation) -> UIView? { 
    let button = UIButton(type: .detailDisclosure) 
    button.tag = 101 
    return button 
} 

func mapView(_ mapView: MGLMapView, annotation: MGLAnnotation, calloutAccessoryControlTapped control: UIControl) { 
    // Hide the callout view. 
    mapView.deselectAnnotation(annotation, animated: false) 

    if control.tag == 100 { 
     print("left") 
    } else if control.tag == 101 { 
     print("right") 
    } 
} 
+0

ありがとうございました!それはまさに私が探していたものです、私は多くを感謝します! – Cal

+0

あなたが気にしないなら、答えを受け入れてください。それはすべてを助けます:) – Magnas

+0

スタックオーバーフローがそれを持っていたことを実現しませんでした!私は新しいです! – Cal