向地图添加注释时出现Swift错误

时间:2016-08-02 20:35:17

标签: ios swift xcode annotations mapkit

我收到错误:EXC_BAD_INSTRUCTION用于此函数的最后两行。在我的代码中,我得到了用户位置,并希望将其用于引脚的位置。提前谢谢!

@IBAction func makeEvent(sender: UIButton)
    {
        self.pointAnnotation1 = MKPointAnnotation()
        self.pointAnnotation1.title = "Event"
        self.pointAnnotation1.coordinate = CLLocationCoordinate2D(latitude: 38.986, longitude: -78.945)
        self.pinAnnotationView = MKPinAnnotationView(annotation: self.pointAnnotation, reuseIdentifier: nil)
        self.mapView.centerCoordinate = self.pointAnnotation.coordinate
        self.mapView.addAnnotation(self.pinAnnotationView.annotation!)
    }

0 个答案:

没有答案