2016-05-18 5 views
1

私は注釈機能でいくつかの吹き出しアクセサリーを作っていましたが、突然注釈ピンが隠されていましたか?彼らは隠されているだけなので、私は注釈があることを知っている場所をタップすると、注釈ビューが表示されます。最悪の部分は、私はちょうど後悔することはできません(Cmd + Z)、プロジェクトが実行されている間、私のコンピュータがダウンした原因になります。私は何が変わったのか分かりません。それはピンを隠すでしょう。私の注釈ピンが隠されています

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { 

    if annotation is MKUserLocation { 
     return nil 
    } 

    let identifier = "MyCustomAnnotation" 

    var annotationView = mapView.dequeueReusableAnnotationViewWithIdentifier(identifier) 
    if annotationView == nil { 
     annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: identifier) 
     annotationView?.canShowCallout = true 

    } else { 

     annotationView!.annotation = annotation 

    } 

    let image = UIImage(named: "advance.png") 
    let button = UIButton(type: .DetailDisclosure) 
    button.frame = CGRectMake(0, 0, 30, 30) 
    button.setImage(image, forState: .Normal) 
    annotationView?.rightCalloutAccessoryView = button 

    let detailImage = UIImageView(frame: CGRectMake(0, 0, 50, 50)) 
    detailImage.image = UIImage(data: fishimages!) 
    annotationView?.leftCalloutAccessoryView = detailImage 


    return annotationView 
} 
+0

'MKAnnotationView()'を呼び出して、未エンキュー*ピン*を割り当ててもよろしいですか?最近の習慣は 'let annotationView = MKPinAnnotationView(注釈:注釈、reuseIdentifier:識別子)'を使うことです。これはいつも非nilピンを返します。 – Grimxn

答えて

0

は隠されますが、透明ではありません!

MKAnnotationView()(既存のものをデキューできない脚に)を割り当てると、ビューの.imageが設定されないため、ピンではなく空白のビューになります。

let annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier) 

これは常に非nilピンを返します。

+0

ありがとう!それはうまくいった – jonask

関連する問題