17

XCode を 6.3 に更新したところ、次のエラーが表示されます。MKPointAnnotation には「setCoordinate」という名前のメンバーがありません。

どこに行ったのか、または他のMKメソッドを使用することになっているのかどうかはわかりません. どんな助けでも大歓迎です。

func refreshlocation(lat:String, lon:String, withOffset:Bool = false){


        // 1 Convert the string values to something that can be used.
        let location = CLLocationCoordinate2D(
            latitude: (lat as NSString).doubleValue as CLLocationDegrees,
            longitude: (lon as NSString).doubleValue as CLLocationDegrees
        )

        // 2 setup some initial variables.
        let span = MKCoordinateSpanMake(
            (self.locationLatitudeDelta as NSString).doubleValue as CLLocationDegrees,
            (self.locationLongitudeDelta as NSString).doubleValue as CLLocationDegrees
        )

        let region = MKCoordinateRegion(center: location, span: span)
        mapView.setRegion(region, animated: true)

        //3 decorate the point and add the point to the map.
        var annotation = MKPointAnnotation()
        annotation.setCoordinate(location) //Error on this line

    }
4

1 に答える 1

23

MapKit モジュールの iOS 8.3 API Diffs に記載されているように、setCoordinateメソッドは削除されました。

MKAnnotation.setCoordinate(CLLocationCoordinate2D) を削除しました


幸いなことに、より単純な割り当て構文を使用する必要があります (以前のバージョンの Swift では既に使用可能であり、Objective-C でも同じことが可能でした)。

annotation.coordinate = location
于 2015-04-10T00:58:23.520 に答える