gpt4 book ai didi

swift - Swift 中的 MKMapRectMake 在编译时导致链接器错误

转载 作者:搜寻专家 更新时间:2023-10-30 23:03:27 25 4
gpt4 key购买 nike

使用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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com