地图视图注释代表swift 3.0

时间:2016-10-05 15:46:47

标签: ios swift swift3 xcode8 mkmapviewdelegate

// MARK: - MapView Delegate
override func mapView(_ mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {

    var anView = mapView.dequeueReusableAnnotationView(withIdentifier: annotationReuseId)

    if anView == nil {
        anView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationReuseId)
    } else {
        anView!.annotation = annotation
    }
    anView!.image = UIImage(named: "Contactus_gatePin")
    anView?.frame = CGRect(x: 0, y: 0, width: 53, height: 53)
    anView!.backgroundColor = UIColor.clear
    anView!.canShowCallout = false
    return anView
}

override func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
    return
}

我在Swift3中遇到此方法的错误。它在Swift2.2中工作 我无法将其转换为Swift 3.0
请帮忙

2 个答案:

答案 0 :(得分:3)

在Swift 3中,viewForAnnotation的{​​{1}}方法更改为此类。

MKMapViewDelegate

其他方法请检查optional func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { } 上的Apple Documentation

答案 1 :(得分:0)

swift 3.0中的

注释方法

using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)){
        data = new byte[fs.Length];
        fs.Read(data, 0, (int)fs.Length);