2017-05-16 18 views
0

내 응용 프로그램에 문제가 있습니다. 사실, 별도의 응용 프로그램에서 코드를 실행하면 작동합니다. xCode가 오류를 표시하지 않고 모든 것이 잘 작동하지만 MapKit의 주석에서 상세 단추를 볼 수 없습니다. xCode에 더 깊은 문제가 있습니까? 내 코드입니다주석의 버튼이 나타나지 않습니다.

:

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

    let identifier = "Education" 

    if annotation is Education { 
     var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) 

     if annotationView == nil { 
      annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier) 
      annotationView!.canShowCallout = true 

      let btn = UIButton(type: .detailDisclosure) 
      annotationView!.rightCalloutAccessoryView = btn 
     } else { 

      annotationView!.annotation = annotation 
     } 

     return annotationView 
    } 

    return nil 
} 

It looks like this on my app - no detail button on the right side of annotation.

답변

0

당신은 당신의지도보기의 대리자를 설정해야합니다. 나는 보통지도보기가에있는의 ViewController의 viewDidLoad에 그것을 할.

mapView.delgate = self

을 추가하는 데 필요한 코드입니다.

+0

모든 것이 작동합니다! 고맙습니다 :) –