core-location

Core Location Best Placement and User Interruption

梦想与她 提交于 2019-12-11 16:57:28
问题 My application uses Core Location in three different views. It's working perfectly. In my first view, I subclass the CLLocationManager and use protocol methods for location updates to my calling class. Before I install the framework and code in my other classes, I was wondering: Is the protocol method the best way? What happens to the Core Location execution if the user exits the view or quits the app while it's trying to get a location fix? Is the location task terminated with the GPS system

Possible to use geofencing (region monitoring) on iOS without “Always” location access?

一笑奈何 提交于 2019-12-11 15:22:58
问题 I wrote some test code that alerts me in the background when I've left a region or entered it. Works great with "Always" location access. — However, if I change the app's location access to "When In Use", it doesn't work anymore. Works again when reverted. I was under the impression (as were others) that geofencing (region monitoring) on iOS should work without "Always" location access. Is there an entitlement or setting somewhere to enable it to work correctly? The hollow arrow doesn't even

What location manager is offering as its recent value

百般思念 提交于 2019-12-11 14:04:16
问题 I asked a question regarding how to get old location from this: - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations And I got reply You should create and use a mutable array of previous locations that were updated from previous calls to "locationManager: didUpdateLocations:". Link Now I am confused regarding that in Location Awareness guide Apple says this: If a location update has already been delivered, you can also get the most recent location data

Swift: location not being updated when returned from background

北慕城南 提交于 2019-12-11 13:29:15
问题 I have a Swift app that I am trying to update the location when the app is returned from the background, but it doesn't seem to work when returned from the background. On launch of the app, I'll get the location just fine. After getting the location I call stopUpdatingLocation() so I don't continue to get the location: locationManager.stopUpdatingLocation() Then, in my AppDelegate.swift I startUpdatingLocation again: func applicationWillEnterForeground(application: UIApplication) {

How can i determine if location information returned by CLLocationManager is valid?

末鹿安然 提交于 2019-12-11 13:16:55
问题 How can I determine if location information returned by CLLocationManager is valid? 回答1: Two things to look for, the timestamp and the hdop (Horizontal Degree of Precision). The first one will tell you when the reading was taken, the second will tell you the level of error in the reading. For example a hdop of 1000 will tell you that the measurement is accurate to within 1000 metres. Obviously the lower the hdop the better. They are both in the Core Location update you get. 回答2: You can't be

How to disable coreLocation in the iPhone simulator?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 12:13:53
问题 How do you disable coreLocation on the iPhone simulator? I'd like to test some stuff but can't find a way to disable it. 回答1: Do it on the device. When the "Would you allowed this app to use your current location" message pops up, then press No. Then you should be able to test it. This message doesn't come up in the simulator 来源: https://stackoverflow.com/questions/1382958/how-to-disable-corelocation-in-the-iphone-simulator

EXC_BAD_ACCESS when setting a CLBeacon to nil

与世无争的帅哥 提交于 2019-12-11 08:33:38
问题 The following will perform a crash when setting CLBeacon to nil . CLBeacon *beacon = [[CLBeacon alloc] init]; beacon = nil; // crash Is it not possible to deallocate an initialized CLBeacon ? This can be reproduced by simply adding the code above to a fresh project inside the App Delegate's didFinishLaunchingWithOptions - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { CLBeacon *beacon = [[CLBeacon alloc] init]; beacon = nil; //

Can't compare two CLLocationCoordinate2Ds (negative zero??)

﹥>﹥吖頭↗ 提交于 2019-12-11 06:53:20
问题 I'm having the hardest time comparing two (what should be identical) CLLocationCoordinate2D structs in my iOS app. For some reason no matter how I compare them, the latitude just won't say it's equal. The code: double dlat = self.mapView.centerCoordinate.latitude - self.centerOnNextView.coordinate.latitude; double dlong = self.mapView.centerCoordinate.longitude - self.centerOnNextView.coordinate.longitude; NSLog(@"dlat: %f dlong: %f, dlat == 0.0: %d, dlat == -0.0: %d, dlong == 0.0: %d, dlong

How to draw Polyline based on route in Mkmapview

心不动则不痛 提交于 2019-12-11 06:02:31
问题 Hi all I need to display Polyline in MKapview . I have done that but I need to show Polyline based on route. I'm getting like below image if am using location did update then it comes good i am try to store latitude and longitude then next time i have to displayed previous Polyline in that time i am not getting, please help me 回答1: - (void)drowRoautLines_FromLocation:(CLLocationCoordinate2D)FromLocation ToLocation:(CLLocationCoordinate2D)ToLocation { MKPlacemark *source = [[MKPlacemark alloc

Ask for only Request Always Authorization, and not When-In-Use Authorization

混江龙づ霸主 提交于 2019-12-11 05:14:09
问题 In iOS 11 onwards we follow these instructions from Apple: You are required to include the NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUsageDescription keys in your app's Info.plist file. (If your app supports iOS 10 and earlier, the NSLocationAlwaysUsageDescription key is also required.) If those keys are not present, authorization requests fail immediately. This shows both "Always" and "When in Use" options when the user is prompted to enable location tracking. However