ios – XCode 6.3 MKPointAnnotation setCoordinate丢失

我刚刚将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

    }

解决方法

iOS 8.3 API Diffs in the MapKit module所述,setCoordinate方法删除

Removed MKAnnotation.setCoordinate(CLLocationCoordinate2D)

幸运的是,您现在必须使用更简单的赋值语法(这在之前版本的Swift中已经可以使用,并且可以在Objective-C中完成):

annotation.coordinate = location

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...