cllocationmanager

iPhone Core Location: Calculate total elevation loss/gain

时光怂恿深爱的人放手 提交于 2019-12-09 21:05:04
问题 I am wanting to calculate total elevation loss and gain at the end of recording Core Location data. I am having a hard time thinking of the math for this one. Say if I started at 600 feet and I go up and down during the tracking, how would I calculate my elevation gain and loss? Ideas? 回答1: If you wanted to track gain and loss separately, keep two cumulative member variables, netElevationLoss and netElevationGain, both initialized to 0. - (void)locationManager:(CLLocationManager *)manager

Background location tracking: iOS

时间秒杀一切 提交于 2019-12-09 19:30:38
问题 I'm trying to decide between Apple's significant location change services and start / stopping the location manager regularly myself. This is what Apple says about it : Gathering location data is a power-intensive operation. It involves powering up the onboard radios and querying the available cell towers, Wi-Fi hotspots, or GPS satellites, which can take several seconds. Leaving the standard location service running for extended periods can drain the device’s battery. (The significant-change

how to return multiple values from a method

試著忘記壹切 提交于 2019-12-09 16:53:08
问题 I have -(CLLocationCoordinate2D) method, I want to return multiple locations from that method (those locations are using in another method) my method looks like this, -(CLLocationCoordinate2D) addressLocation{ - -------- ---------- return location; } is it possible to return multiple locations (I mean return location1 , return location2 . . ..) ?? please help me thanks 回答1: Add your location objects to an array and return the array instead. e.g. -(NSArray*) addressLocation{ ... // Set your

check if a user allows the app to use their location

拈花ヽ惹草 提交于 2019-12-09 16:43:19
问题 The first time the app tries to get the users location they are prompted with "Would like to use your current location" and they can hit Don't allow or ok. Is there any way to find out if the user has hit ok or don't allow? I'm trying to have the MKMapView show the users current location but I would like to take different actions based on the users selection. Normally you would think there would be a delegate to get this information but there doesn't seem to be. Thanks in advance for your

CLLocationManager didUpdateLocations not being called

半城伤御伤魂 提交于 2019-12-09 03:24:51
问题 I am in the process of learning iOS 8 app development with Swift. I have followed a tutorial on Treehouse that walks you through building a weather app in Swift and iOS 8. As an improvement to the app, the author/tutor suggests using CLLocationManager to get the location of the device to feed into the weather API instead of the hard coded latitude and longitude values. So having read various tutorial online, I have gone ahead and attempted to implement this suggested improvement. I have

Receiving CLLocation updates on a background thread

烈酒焚心 提交于 2019-12-09 01:05:52
问题 I am trying to implement a (non-concurrent) NSOperation for location updates using the iPhone SDK. The "meat" of the NSOperation subclass goes something like this: - (void)start { // background thread set up by the NSOperationQueue assert(![NSThread isMainThread]); if ([self isCancelled]) { return; } self->locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = self->desiredAccuracy; locationManager.distanceFilter = self->filter;

Localizing the user on iOS 8

南笙酒味 提交于 2019-12-08 20:13:58
问题 Hullo, I am starting to port my apps to iOS 8 and I soon bounced into a problem with CLLocationManager. Basically the app no longer centers the map on the user's location and instead proposed error: Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first. Executing [CLLocationManager requestAlwaysAuthorization] does nothing and even inserting the

Location Manager stopMonitoringForRegion Not Working

左心房为你撑大大i 提交于 2019-12-08 19:14:32
问题 An app I'm working on currently sets up region monitoring with the user's current location when the app is backgrounded. When the app becomes active again I am trying to stop monitoring for the region, but it seems to work intermittently with the majority of the time resulting in it failing to act as expected. When the app is backgrounded, I start monitoring for the region and it works fine when I log the details: - (void)locationManager:(CLLocationManager *)manager

NSLocationAlwaysUsageDescription string added in info.plist is not showing in permission popup ios

风流意气都作罢 提交于 2019-12-08 15:55:44
问题 <key>NSLocationAlwaysUsageDescription</key> <array> <string>Location is required to find out where you are</string> </array> <key>Privacy-Location Usage Description</key> <string>Location is required to find out where you are.</string> I have added this in info.plist. Still the permission popup does not shows the string added,Instead it shows-- Allow "app" to access your location even when you are not using the app? 回答1: Use CLLocationManager Add the following line in your Info.plist file

MY IOS App is not getting any region updates when ever I restart my device any ideas?

主宰稳场 提交于 2019-12-08 14:24:12
问题 My app is working fine for beacon monitoring when running in foreground and background even when I quit app it's launching the app in background .. But when I restart the phone it's not waking up.. // I am using background modes for location also func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { //do i have to do anything here return true } //when ever app hit background bellow method will trigger and