Swift中的MKMapRectMake在编译时会导致链接器错误
发布时间:2020-12-14 04:41:52 所属栏目:百科 来源:网络整理
导读:使用MKMapRectMake创建MKMapRect会导致编译错误,如下所示: 这是我的代码: var lat = 37.33072 var lon = -122.029674 var loc = CLLocationCoordinate2D(latitude: lat,longitude: lon) var point = MKMapPointForCoordinate(loc) var flyTo = MKMapRectMa
使用MKMapRectMake创建MKMapRect会导致编译错误,如下所示:
这是我的代码: var lat = 37.33072 var lon = -122.029674 var loc = CLLocationCoordinate2D(latitude: lat,longitude: lon) var point = MKMapPointForCoordinate(loc) var flyTo = MKMapRectMake(point.x,point.y,0); 这是编译器的错误: Undefined symbols for architecture i386: "_MKMapPointMake",referenced from: _MKMapRectMake in ViewController.o "_MKMapSizeMake",referenced from: _MKMapRectMake in ViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) 我的解决方法是使用origin和size参数创建MKMapRect.请注意,我已将MKMapKit添加到Build Phases中的链接库中 有没有人遇到同样的问题以及你如何解决这个问题? 解决方法
使用实用功能解决它:
func myMKMapRect(x: Double,y:Double,w:Double,h:Double) -> MKMapRect { return MKMapRect(origin:MKMapPoint(x:x,y:y),size:MKMapSize(width:w,height:h)) } 当然,还要向Apple提交错误报告. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |