cllocationmanager

iOS 12 terminates apps in the background for no reason

雨燕双飞 提交于 2019-12-17 17:33:39
问题 Starting from iOS 12 the CLLocationManager doesn't run endless anymore in the background. The app get's terminated without a crashlog at random times. This was working fine before iOS 12. To demonstrate this problem I've created an sample app here The demo app just launches an CLLocationManager and keep this running in the background. While running on the background we keep track of it by logging it. The problem is that the app get terminated by iOS. The demo app is created to demonstrate

How to set accuracy and distance filter when using MKMapView

我的未来我决定 提交于 2019-12-17 17:28:28
问题 When i use setShowsUserLocation with MKMapView to track user location, how do I set the accuracy and distance filter? I am not talking about CLLocationManager . Thanks, 回答1: You can't control the accuracy of the internal MKMapView location manager (the one used to track the user with the blue dot), but you can create your own and use it to recenter the map. Here is a recipe... To handle core location permissions In the Core Location Delegate: - (void)locationManager:(CLLocationManager *

Checking location service permission on iOS

只愿长相守 提交于 2019-12-17 17:25:16
问题 How can I check if location service is enabled for my app? I have 2 storyboards and I want to check location service. If location service enabled for my app, I want to launch map storyboard with location. Otherwise, I want to launch another storyboard. How can I do programmatically? 回答1: This is the correct. if ([CLLocationManager locationServicesEnabled]){ NSLog(@"Location Services Enabled"); if ([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied){ alert = [[UIAlertView

Cannot get rid of Optional() string

吃可爱长大的小学妹 提交于 2019-12-17 17:08:07
问题 I am trying to update users location on server Using this function func updateloc(lat : String?, long : String?) { /code... let data = "lat=\(lat!)&long=\(long!)" } And here is the delegate func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { updateloc(String(manager.location?.coordinate.latitude), long: String(manager.location?.coordinate.longitude)) } I have Optional("") for lat and long variables and cannot get rid of it. Any idea how to do that?

MapKit in Swift, Part 2

人走茶凉 提交于 2019-12-17 17:00:17
问题 I'm trying work with Map Kit in Swift. I try to display the area on the map, one pin (MKPinAnnotationView) and the current position. All display fine. I try to add Disclosure Button and intercept tapping on it. Disclosure Button added, but does not work intercept tapping. Function pinPressed with method calloutAccessoryControlTapped not work.... This is a sample code: import UIKit import MapKit import CoreLocation class ViewController: UIViewController, MKMapViewDelegate,

didUpdateLocations not called

柔情痞子 提交于 2019-12-17 15:36:10
问题 I'm trying to get my current location, but the break point in didUpdateLocations is never being called. LocationManager: locationManager = [[CLLocationManager alloc] init]; [locationManager setDelegate:self]; [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [locationManager setDesiredAccuracy:kCLDistanceFilterNone]; [locationManager startUpdatingLocation]; Delegate method: - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations; I confirmed

How to rotate a Direction Arrow to particular location

喜夏-厌秋 提交于 2019-12-17 10:35:12
问题 In my app I have a latitude-longitude of 1 fix location. Now user with iPhone device can move anywhere and even he rotate his device, the arrow (some uiimageview) should point to that fix location so User will get direction to that location every time. I tried as follows. -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CLLocationCoordinate2D here = newLocation.coordinate; [self calculateUserAngle:here];

iOS: App is not asking user's permission while installing the app. getting kCLAuthorizationStatusNotDetermined every time - Objective-c & Swift

╄→尐↘猪︶ㄣ 提交于 2019-12-17 06:25:34
问题 I am trying to fetch user location in my iOS app. I have included corelocation framework in my project first. Then on a button click I am invoking the core location api as below. When I am trying to install this in a device, the core location never asks the user permission. When I try to fetch the location on button click, I am getting kCLAuthorizationStatusNotDetermined as the authorisationStatus. Please help me in this. I have no clue what is happening. - (IBAction)fetchLessAccurateLocation

Does startMonitoringForRegion actually work?

梦想与她 提交于 2019-12-14 03:49:05
问题 I've been trying to use startMonitoringForRegion for while, but experiencing problems to capture enter/exit events. When I launch the app on simulator and moved to the location I specified, I get 1 enter event, but enter events never triggered again. Can somebody let me know if I'm doing correctly? test.h #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> @interface EWViewController : UIViewController<CLLocationManagerDelegate> { CLLocationManager *locman; } @end test.m - (void

Getlocation function not properly finding location

余生长醉 提交于 2019-12-14 03:14:21
问题 My code is supposed to return the location of the device, for the purposes of placing a pin. For some reason when it is called multiple times, it always returns the value returned the first time it was called. The prints in the code are returning the first value. I am probably overlooking something obvious, but I cannot figure out what. func getLocation ()-> CLLocation! { locationManager.startUpdatingLocation() var x = locationManager.location println(x.coordinate.latitude) println(x