0

我正在使用包含图像的自定义点注释。我收到了几个错误,例如“计算属性必须具有显式类型”和“带有 getter/setter 的变量不能具有初始值”和 var 注释行。如果我修复另一个弹出。有谁知道如何在 Swift 3 中实现这一点?

func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {

        let eventPageViewController:EventPageViewController = storyboard?.instantiateViewController(withIdentifier: "EventPage") as! EventPageViewController

        var annotation = view.annotation as? CustomPointAnnotation{
            eventPageViewController.photo = annotation?.imageName
        }

        self.present(eventPageViewController, animated: true, completion: nil)
    }

这是自定义点类:

class CustomPointAnnotation: MKPointAnnotation {
    var imageName: UIImage!
}
4

1 回答 1

0

这是对我有用的解决方案:

let annotation1 = view.annotation as! CustomPointAnnotation
eventPageViewController.photo = annotation1.imageName
于 2017-02-07T19:33:58.943 回答