jjzjj

CLLocation

全部标签

ios - 在 Swift 中,我可以检测 CLLocation 是否有效吗?

我正在将一个位置传递给另一个UIViewController,它有一个使用prepareForSegue的MapView。我称之为receivedLocation。map以经过的位置为中心。如果用户在没有先发送位置的情况下单击按钮将他们带到map,这不会失败吗?我如何测试以查看receivedLocation是否确实包含数据,以便在map为空时将map设置为以其他内容为中心?是否会创建一个bool变量,最初将其设置为false,但在传递位置并测试时将其设置为true能否如我所愿?我看到一个名为CLLocationCoordinateIsValid的东西可用,但它的参数是一个2DCoor

swift - 尝试将 CLLocation 对象传回 iOS 应用程序扩展时,字典变为零

我正在尝试将存储的CLLocation对象从我的iOS应用程序传回扩展程序(在这种情况下:AppleWatch扩展程序)。为此,我使用推荐的openParentApplication(userInfo:[NSObject:AnyObject]!,reply:(([NSObject:AnyObject]!,NSError!)->Void)!)->Bool扩展代码中WKInterfaceController类的函数。我通过应用程序委托(delegate)的application(application:UIApplication!,handleWatchKitExtensionReques

core-data - 在 CoreData 中保存 Swift CLLocation

我试图在CoreData中保存CLLocation数据。我的属性设置为Transformable对象。那里的一些示例代码表明可以使用转换为NSValue的对象来保存位置数据。CLLocationCoordinate2DmyLocation;NSValue*locationValue=[NSValuevalueWithBytes:&myLocationobjCType:@encode(CLLocationCoordinate2D)]//thenputlocationValueintostorage-maybeanObjCcollectionclassorcoredataetc.从数据存储

swift - CLLocation distanceFromLocation(在 Swift 中?)

有人可以帮我将以下Objective-C语句转换为Swift吗?CLLocationDistancedistance=[fromLocationdistanceFromLocation:toLocation];我知道这样做一定很简单。我是iOS编程的新手,非常感谢任何帮助。谢谢!:-) 最佳答案 letdistance=fromLocation.distanceFromLocation(toLocation)新语法:letdistance=aLocation.distance(from:anotherLocation)

ios - CLLocation 的 horizo​​ntalAccuracy 和 verticalAccuracy 指的是什么?

我最近一直在开发一个基于位置的应用程序,我注意到CLLocation有一些奇怪的值。我经常得到1414的horizo​​ntalAccuracy和-1的verticalAccuracy。任何线索这表明什么?据我所知,这些观点通常非常准确。verticalAccuracy和horizo​​ntalAccuracy有什么区别? 最佳答案 verticalAccuracy的-1表示CLLocation中的高度无效。您只能通过3DGPS位置获得高度。horizo​​ntalAccuracy的1414表示水平(纬度/经度)位置可能偏离1414

ios - 将 CLLocationCoordinate2D 放入 Swift 的 CLLocation

我有一个方法想调用,但是当我回到map中心时,它是CLLocationCoordinate2D类型。如何将CLLocationCoordinate2D的结果放入CLLocation中? 最佳答案 想通了。当mapView改变区域时,从CLLocationCoordinate2D中获取Lat和Lon,并创建一个CLLocation变量,并将lat和lon传入。funcmapView(mapView:MKMapView!,regionDidChangeAnimatedanimated:Bool){varcentre=mapView.ce

swift - 使用纬度和经度在 swift 中初始化 CLLocation 对象

在objective-c中(我没有这方面的经验)你可以像这样用纬度和经度初始化一个CLLocation对象:CLLocation*myLocation=[[CLLocationalloc]initWithLatitude:your_latitiude_valuelongitude:your_longitude_value];但是我如何在Swift中做到这一点?我试过了,letloc_coords=CLLocationCoordinate2D(latitude:your_latitiude_value,longitude:your_longitude_value)letloc=CLLoc

cllocationmanager - Swift 中的 CLLocation Manager 获取用户位置

我正在尝试将ObjC中的旧应用程序转换为Swift作为练习,但遇到了一些问题。我在旧应用程序中的方式是建立CLLocation管理器,然后我将使用:manager=[[CLLocationManageralloc]init];manager.delegate=self;manager.desiredAccuracy=kCLLocationAccuracyBest;[managerstartUpdatingLocation]它会自动调用:-(void)locationManager:(CLLocationManager*)managerdidUpdateToLocation:(CLLoc