作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
使用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, 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 添加到构建阶段中的链接库中
有没有人遇到同样的问题,你们是如何解决的?
最佳答案
使用实用函数解决它:
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 提交错误报告。
关于swift - Swift 中的 MKMapRectMake 在编译时导致链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24802814/
使用MKMapRectMake创建MKMapRect会出现如下编译错误: 这是我的代码: var lat = 37.33072 var lon = -122.029674 va
我是一名优秀的程序员,十分优秀!