标签: cllocationmanager

MBProgressHUD阻止用户交互

我的应用程序MBProgressHUD在屏幕上有一个CLLocationManager用户当前位置在后台的一个单独的线程.有时位置过程开始花费这么长时间,显然我想让用户决定离开或不离开屏幕.问题是用户界面似乎被阻止,MBProgressHUD因此用户无法按下后退按钮.

有没有任何实现设计来解决这个问题?

objective-c nsthread cllocationmanager mbprogresshud

33
推荐指数
1
解决办法
8808
查看次数

didUpdateLocations未调用

我正在尝试获取当前位置,但是didUpdateLocations中的断点永远不会被调用.

的LocationManager:

locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager setDesiredAccuracy:kCLDistanceFilterNone];
[locationManager startUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)

代表方法:

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations;
Run Code Online (Sandbox Code Playgroud)

我确认了位置服务并启用并授权.

为什么没有像它应该调用locationManager委托方法?

谢谢,迈克

xcode objective-c cllocationmanager cllocation ios

31
推荐指数
4
解决办法
3万
查看次数

IOS 9错误域= kCLErrorDomain代码= 0"(null)"

下面的代码应该获得当前位置.但是会产生上述错误.函数didUpdateLocations永远不会被调用.

在设备(iPhone 5s)iOS 9.1上运行此功能.Info.plist具有所需的设备功能和隐私 - 配置位置使用说明,如附图所示.请帮忙!

let locationManager = CLLocationManager()

override func viewDidLoad() {
    super.viewDidLoad()
    locationManager.delegate = self
    locationManager.requestAlwaysAuthorization()
    locationManager.requestLocation()
}


func locationManager(manager: CLLocationManager,
    didFailWithError error: NSError) 
    print(error.description)
}

func locationManager(manager: CLLocationManager, didUpdateLocations
      locations: [CLLocation]) {        
 print(“got location”)
}
Run Code Online (Sandbox Code Playgroud)

的Info.plist

iphone cllocationmanager ios9

31
推荐指数
2
解决办法
3万
查看次数

使用iOS地理围栏跟踪多个(20+)位置

iOS应用程序使用地理围栏来通知用户有关预定义的附近位置.允许应用程序错过某个位置(用户没有收到有关附近位置的通知),但是希望保持较低的丢失率.

实现这一目标的一种方法是开始监控重要的变更位置,startMonitoringSignificantLocationChanges并且每次"位置变更"事件被触发时,查找位于报告位置的500米半径内的位置.

令我担心的是,每次发生重大位置变化时都需要对附近区域执行查询,这会影响电池.

另一种方法是注册地点,startMonitoringForRegion但Apple对同时跟踪的地区数量(合理)限制为20,我们有超过20个地点.因此需要对跟踪区域进行某种动态更新,但我仍然不确定最佳方法是什么.

有关如何做到这一点的任何想法,以便它保持低电池消耗,但也具有低位置的丢失率?

location cllocationmanager ios geofencing

30
推荐指数
3
解决办法
1万
查看次数

使用MKMapView时如何设置精度和距离滤镜

当我使用setShowsUserLocationMKMapView跟踪用户的位置,我该如何设置的准确性和距离过滤器?我不是在谈论CLLocationManager.

谢谢,

iphone mkmapview cllocationmanager ipad ios

29
推荐指数
1
解决办法
4万
查看次数

暂停后iPhone背景中的iPhone GPS永远不会恢复

我的应用程序需要在后台跟踪用户位置更改,并且只要用户移动就可以正常工作.当用户CLLocationManager在10-20分钟左右停止并暂停时.此通知表明:

-(void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager{}
Run Code Online (Sandbox Code Playgroud)

这对我也没关系.太棒了,我节省了一些电池等

问题是CLLocationManager当用户再次开始移动时永远不会醒来,并且在我将应用程序放到前台之前永远不会触发委托方法(获取活动):

//Never called back after CLLocationManager pauses:
-(void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager{}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{}
Run Code Online (Sandbox Code Playgroud)

为什么locationManagerDidResumeLocationUpdates在设备重新开始移动后从未调用过?GPS也不应自动恢复(因为自动暂停)? 有没有办法在没有用户互动的情况下恢复GPS?

应用程序在Info.plist文件中声明如下:

在此输入图像描述

我的CLLocationManager设置是:

locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager setActivityType:CLActivityTypeFitness];
//I WANT pauses to save some battery, etc... That is why following line is commented out (default)
 //[locationManager setPausesLocationUpdatesAutomatically:NO];
 locationManager.distanceFilter = kCLLocationAccuracyNearestTenMeters;
 locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
 [locationManager startUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)

objective-c core-location uiapplicationdelegate cllocationmanager ios

29
推荐指数
1
解决办法
9324
查看次数

iOS Geofence CLCircularRegion监控.locationManager:didExitRegion似乎没有按预期工作

我目前正试图让我的应用程序监控特定区域使用CoreLocation但是我发现它似乎没有按预期工作,在我看来,它不能用于每个位置的小半径设置,即10米.

我还整理了一个小测试应用程序,在地图上绘制圆形半径,以便我可以直观地看到发生了什么.

我用于监控位置的代码如下:

self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;

// Set-up a region
CLLocationDegrees latitude = 52.64915;
CLLocationDegrees longitude = -1.1506367;
CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(latitude, longitude);

CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:centerCoordinate
                                                                 radius:10 // Metres
                                                             identifier:@"testLocation"];

[self.locationManager startMonitoringForRegion:region];
Run Code Online (Sandbox Code Playgroud)

我没有在这里为DidEnter区域等提出代码,因为我知道当我离监控区域超过100米时可以工作.

这是应用程序的屏幕截图,当我距离地图上的紫色位置超过10米时,确实的出口区域事件不会触发,但是如果我将我的位置切换到伦敦则会触发它以及当我设置我的位置时回到目前蓝色位置的地方它也会发射.

示例区域

有没有人知道最小区域半径是否有限制,或者我做错了什么.

谢谢亚伦

core-location cllocationmanager ios geofencing clcircleregion

29
推荐指数
4
解决办法
2万
查看次数

Swift中的CLLocation Manager获取用户位置

我试图将ObjC中的旧应用程序转换为Swift作为练习练习并且遇到了一些问题.我在旧应用程序中使用它的方式,它是建立CLLocation Manager然后我会使用:

manager = [[CLLocationManager alloc]init];
manager.delegate = self;
manager.desiredAccuracy = kCLLocationAccuracyBest;    
[manager startUpdatingLocation]
Run Code Online (Sandbox Code Playgroud)

会自动调用:

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
}
Run Code Online (Sandbox Code Playgroud)

从那里我可以提取我需要的所有信息.但是在swift中,没有自动完成这种方法,我无法弄清楚如何重现它.文档说明了这一点

startUpdatingLocation()
Run Code Online (Sandbox Code Playgroud)

仍将由代表调用,但它没有发生.

这是我到目前为止:

import UIKit
import corelocation

class ViewController: UIViewController,CLLocationManagerDelegate{

@IBOutlet var gpsResult : UILabel

var manager:CLLocationManager!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    manager = CLLocationManager()
    manager.delegate = self
    manager.desiredAccuracy = kCLLocationAccuracyBest
    manager.startUpdatingLocation()
}

func locationManager(manager:CLLocationManager, didUpdateLocations locations:AnyObject[]) {
    println("locations = \(locations)")
    gpsResult.text = "success" …
Run Code Online (Sandbox Code Playgroud)

cllocationmanager swift

28
推荐指数
3
解决办法
9万
查看次数

CLLocationManager和准确性问题 - 任何经验?

所以我正在处理iPhone GPS的一些准确性问题.我有一个使用位置的应用程序.

在委托方法中,locationManager: didUpdateToLocation: fromLocation:我正在返回一个位置.从一些研究来看,似乎GPS在返回的第一个结果上并不总是准确的,即使设置desiredAccuracy属性也是如此kCLLocationAccuracyBest.

为了解决这个问题,我不会stopUpdatingLocation在它返回newLocation:至少3次之前打电话(这很快).我还玩过两个关于是否stopUpdatingLocation返回的"要求" newLocation.我尝试的一种方法是检查lat和long newLocation并进行比较oldLocation,如果这些不相同,则保持位置更新运行.我也试图与检查之间的距离oldLocationnewLocation,如果它小于20米,它的罚款.这两个都是通过返回至少3次运行来测试的.后一种方式不那么"严格",因为如果用户在移动的车辆中,newLocation并且oldLocation很难与100%完全相同.

现在,我的问题是,即使在进行上述操作时(基本上不接受某个位置,直到发生一些更新并CLLocationManager检查CLLocations它们之间的距离(或者它们是否相同),我仍然看到有时奇怪的位置结果,在测试时.

如果我离开应用程序,进入Maps.app,使用GPS,然后打开多任务处理,强制退出我的应用程序,然后重新打开它以获得干净的启动,有时会修复.

人们习惯于解决同类问题的经验和可能的解决方案?评论和解决方案赞赏:)

cllocationmanager cllocation ios

27
推荐指数
1
解决办法
2万
查看次数

如何在ios中多次停止调用didUpdateLocations()的方法

这是我的代码......

 -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
 {

    location_updated = [locations lastObject];
    NSLog(@"updated coordinate are %@",location_updated);
    latitude1 = location_updated.coordinate.latitude;
    longitude1 = location_updated.coordinate.longitude;

    self.lblLat.text = [NSString stringWithFormat:@"%f",latitude1];
    self.lblLon.text = [NSString stringWithFormat:@"%f",longitude1];

    NSString *str = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false",latitude1,longitude1];
    url = [NSURL URLWithString:str];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    connection = [NSURLConnection connectionWithRequest:request delegate:self];
    if (connection)
    {
        webData1 = [[NSMutableData alloc]init];
    }
        GMSMarker *marker = [[GMSMarker alloc] init];
        marker.position = CLLocationCoordinate2DMake(latitude1,longitude1);
        marker.title = formattedAddress;
        marker.icon = [UIImage imageNamed:@"m2.png"];
        marker.map = mapView_;
        marker.draggable = YES;
 }
Run Code Online (Sandbox Code Playgroud)

这个方法多次调用,我不想......

iphone cllocationmanager cllocation ios

27
推荐指数
4
解决办法
2万
查看次数