Явно новичок в iOS dev, и я следую «первым шагам с помощью iOS MapBox SDK» для Swift (https://www.mapbox.com/help/first-steps-ios-sdk/). Все было хорошо с отображением карты, пользовательским стилем и добавлением аннотации. Но затем возникла проблема при попытке взаимодействия с аннотацией для отображения ее названия и субтитров.аннотация iOS Mapbox не открывается
print("allow")
print("tap on callout")
, кажется, никогда не вызываются. Даже mapView.selectAnnotation(point, animated: true)
ничего не делает (и это не было ничего делать без нее тоже)
Использования Xcode 8.0, MacOS Sierra, Swift 3 прошивки 10
Я немного невежественной сейчас, любой совет будет следует понимать
Спасибо заранее
ViewController.swift:
import UIKit
import Mapbox
class ViewController: UIViewController{
@IBOutlet var mapView: MGLMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let point = MGLPointAnnotation()
point.coordinate = CLLocationCoordinate2D(latitude: 46.082666, longitude:7.508510)
point.title = "Title"
point.subtitle = "Subtitle"
mapView.addAnnotation(point)
mapView.selectAnnotation(point, animated: true)
print("add annotation");
}
// Return `nil` here to use the default marker.
func mapView(mapView: MGLMapView, viewForAnnotation annotation: MGLPointAnnotation) -> MGLAnnotationView? {
print("default marker")
return nil
}
// Allow callout view to appear when an annotation is tapped.
func mapView(mapView: MGLMapView, annotationCanShowCallout annotation: MGLPointAnnotation) -> Bool {
print("allow")
return true
}
func mapView(mapView: MGLMapView, tapOnCalloutForAnnotation annotation: MGLAnnotation) {
print("tap on callout")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Screenshot: Annotation displays where it's supposed to but cannot be interacted with
установлен ли MAPview делегат вверх? – Sealos
Есть ли у вас такая же настройка, как https://www.mapbox.com/help/first-steps-ios-sdk/#ib-set-delegate – Spitfire4466
Твои метки уже указывают на то, что вы используете Swift. Нет необходимости добавлять это в заголовок. –