에 대한 sourceView로 MGLAnnotationView을 설정하는 방법 ,하지만 전혀 실행되지 않는 것 같습니다. 지금은 단지 didSelect 주석를 통해 내 팝 오버를 제시하고있어 그냥 어딘가에을 보여주는, 줄을 탐색 할 수있는 sourceView을 설정 한 내용은 ... 참고로내가하고 싶은 것은 내가 이것을 달성 할 수 있어야한다 위임 기능 <strong>didSelect annotationView</strong>을 사용하여 소스보기/앵커</strong></p> <p>과 주석과 팝 오버를 제시 <strong>입니다 팝 오버
: 나는 프로젝트에 Mapbox SDK을 구현 한 . MapKit을 사용하여 동일한 작업을 수행하는 데 문제가 없습니다.
아무에게도 이것을 달성하기 위해 내가 할 수있는 일이 있습니까?
아래 코드 스 니펫 : 선택할 수있는 주석보기,이 없기 때문에
import UIKit
import Mapbox
class ViewController: UIViewController, MGLMapViewDelegate, UIPopoverPresentationControllerDelegate {
@IBOutlet var theMap: MGLMapView!
override func viewDidLoad() {
super.viewDidLoad()
theMap.delegate = self
let point = MGLPointAnnotation()
point.coordinate = CLLocationCoordinate2D(latitude: 55.6, longitude: 13.0)
point.title = "Some place"
point.subtitle = "Malmö, Sweden"
theMap.addAnnotation(point)
}
func mapView(_ mapView: MGLMapView, didSelect annotationView: MGLAnnotationView) {
print("annotation view: ", annotationView)
// this method doesn't seem to get called at all...
// but ideally this is the place to present the popover.
}
func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) {
print("annotation: ", annotation)
// present the popover
presentPopover()
}
func presentPopover(){
let popover = storyboard?.instantiateViewController(withIdentifier: "MyCalloutVC") as! MyCallout
popover.modalPresentationStyle = UIModalPresentationStyle.popover
popover.popoverPresentationController?.backgroundColor = UIColor.white
popover.popoverPresentationController?.delegate = self
// I would like to set the source anchor to the selected annotation view.
popover.popoverPresentationController?.sourceView = UINavigationBar() // set to nav bar for now...
popover.popoverPresentationController?.permittedArrowDirections = .any
// popover size set in MyCallout
self.present(popover, animated: true)
}
}
설명 답, 적절한 정보를 주셔서 감사합니다. ppoh71! 나는 지금 가고있다. –