gpt4 book ai didi

xcode - 无法将类型 'CLLocationDirection'(又名 'Double')的值转换为预期的参数类型 'Float'

转载 作者:行者123 更新时间:2023-11-28 11:07:44 26 4
gpt4 key购买 nike

我有这段代码,它给我和错误 无法将类型 'CLLocationDirection'(又名 'Double')的值转换为预期的参数类型 'Float' on arrowImageView.transform = CGAffineTransformMakeRotation (CGFloat(self.degreesToRadians(direction)))。请帮我修一下。谢谢。

  func locationManager(manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {

var direction: CLLocationDirection = newHeading.magneticHeading

if direction > 180 {
direction = 360 - direction
}
else {
direction = 0 - direction
}

// Rotate the arrow image
if let arrowImageView = self.arrowImageView {
UIView.animateWithDuration(1.0, animations: { () -> Void in
arrowImageView.transform = CGAffineTransformMakeRotation(CGFloat(self.degreesToRadians(direction)))

})

是否也可以让 compass 指向用户指定的经纬度?你能教我怎么做吗?非常感谢。

最佳答案

Swift 的原始类型不可互换(与 Objective-C 不同)

要么让你的degreesToRadians函数也符合Double
或者你必须从 direction

创建一个 Float
arrowImageView.transform = CGAffineTransformMakeRotation(CGFloat(self.degreesToRadians(CGFloat(direction))))

关于xcode - 无法将类型 'CLLocationDirection'(又名 'Double')的值转换为预期的参数类型 'Float',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36724247/

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