标签: cllocationmanager

使用CLLocationManager和MKReverseGeocoder获取城市名称

我试图通过使用MKReverseGeoCoder获取用户当前位置的城市名称,但它有一些我无法识别的错误.以下是详细信息:

它有一些我无法识别的错误

Undefined symbols:
  ".objc_class_name_CLLocationManager", referenced from:
      literal-pointer@__OBJC@__cls_refs@CLLocationManager in mapViewController.o
  "_kCLLocationAccuracyNearestTenMeters", referenced from:
      _kCLLocationAccuracyNearestTenMeters$non_lazy_ptr in mapViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

在这里;我的代码:

mapViewController.m

//
//  mapViewController.m
//  map
//
//  Created by Ashutosh Tiwari on 7/23/10.
//  Copyright ISU 2010. All rights reserved.
//
#import <MapKit/MapKit.h>
#import "mapViewController.h"

@implementation mapViewController


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    CLLocationManager *locationManager = [[[CLLocationManager alloc] init] autorelease]; …
Run Code Online (Sandbox Code Playgroud)

objective-c mkmapview cllocationmanager mkreversegeocoder

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

iOS:CLLocationManager的maximumRegionMonitoringDistance测量单位

我正在使用iOS中的CLLocationManager的maximumRegionMonitoringDistance属性.当我打印出这个值时,我得到了2,128,000,但我找不到任何关于这个测量单位的文档.有什么想法吗?

2,128,000秒相当于~591度

cllocationmanager ios

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

ios7中的重大blocation更改事件 - 后台服务调用

我在我的应用程序中使用重要的位置服务.如果我的应用程序被系统杀死或用户强行关闭,使用重要位置更改服务事件我将位置数据发送到我的服务器,在iOS 6中.在iOS6中,我的应用程序也会在强制关闭后将数据发送到服务器.但是在iOS 7中,我没有得到这个重要的位置变更事件.

cllocationmanager locationmanager ios

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

iBeacon测距和接近是有缺陷的

我正在上课来处理我所有的iBeacon测试.它的目的是开始寻找区域,范围信标,识别它们然后发送通知.代码如下.

我遇到的问题是应用程序运行速度非常慢,我知道iBeacons有延迟问题,有时只是停止工作(不会识别关闭信标).我知道,我的代码很混乱,在我清理它之前尝试对逻辑进行排序.我想知道我是否错过了一个逻辑缺陷(我的意思是,我想知道我引入了哪些逻辑漏洞!).

#import "dcBeaconManager.h"

@implementation dcBeaconManager

@synthesize currentBeaconState;

bool testRanging = false;
int firstRegionEntered = 0;
int beaconsRangedCount = 0;

- (void)initBeaconManager {
    NSLog(@"initBeaconManager called");
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    NSUUID *uuid = [[NSUUID alloc]initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"];
    self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"digiConsRegion"];
    [self.locationManager startMonitoringForRegion:self.beaconRegion];
    [self.locationManager requestStateForRegion:self.beaconRegion];

    currentBeaconState = @"initial";
}

- (void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region {
    NSLog(@"Started looking for regions");
    [self.locationManager requestStateForRegion:self.beaconRegion];
}

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
    NSLog(@"Region discovered");
    if (firstRegionEntered == 0) {
        NSLog(@"First time …
Run Code Online (Sandbox Code Playgroud)

cllocationmanager nsnotificationcenter ios ibeacon

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

测距信标间隔

在iOS上,在我的应用程序委托中,我开始进行区域监视,一旦进入信标区域,我就使用locationManager:didRangeBeacons:inRegion启动测距逻辑.根据Apple文档,只有当区域在范围内或超出范围或范围发生变化时,才应调用此方法.

我的问题是,只要我在区域内,我每秒都会调用此方法.如何在仍然测距的情况下减少对此方法的调用次数?

region cllocationmanager ios ibeacon

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

iOS 8和iBeacon - kCLErrorRegionMonitoringDenied

过去几个月我一直在和iBeacons合作.我刚刚更新到iOS8 Beta 1,并发现区域监控和测距不再适用于我的beacon应用程序.

它是由权限引起的.我现在kCLErrorRegionMonitoringDenied在尝试启动区域监视时返回错误.此错误对应于用户取消选择应用程序的位置权限.

如果我进入设置>隐私>位置服务,我会得到一些奇怪的行为.有时我的应用程序会显示在此列表中而未选择任何设置,有时它根本不会出现在列表中.如果我手动将设置更改为"允许"然后关闭设置,然后返回设置>隐私>位置服务我遇到同样的问题 - 应用程序可能不会出现在列表中或设置未设置.

这显然是iOS8测试版中的一个错误,只是想知道是否有其他人有此问题和/或找到了解决方法?

cllocationmanager ios ibeacon ios8

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

IOS 8 CLLocationManager问题(授权不起作用)

#import "MyLocationViewController.h"
#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);

@interface MyLocationViewController ()

@end

@implementation MyLocationViewController

{
    CLLocationManager *locationManager;
}

- (void)requestAlwaysAuthorization
{
    [locationManager requestAlwaysAuthorization];
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.
    self.mapView.showsUserLocation = YES;
    self.mapView.delegate = self;
    locationManager = [[CLLocationManager alloc] init];

}

- (IBAction)unwindToMap:(UIStoryboardSegue *)segue
{

}

- (IBAction)getCurrentLocation:(id)sender {
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];
}

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    MKCoordinateRegion …
Run Code Online (Sandbox Code Playgroud)

cllocationmanager ios

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

CLLocationManager didUpdateLocations未被调用

我正在使用Swift学习iOS 8应用程序开发.我已经按照Treehouse上的教程指导您在Swift和iOS 8中构建天气应用程序.

作为对应用程序的改进,作者/导师建议使用CLLocationManager以获取设备的位置以馈送到天气API而不是硬编码的纬度和经度值.

因此,在线阅读了各种教程后,我继续尝试实施这一建议的改进.

我已经放置了负责获取AppDelegate.swift文件中位置坐标的代码.

AppDelegate.swift代码

import UIKit
import CoreLocation

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {

    var window: UIWindow?
    var locationManager: CLLocationManager!
    var errorOccured: Bool = false
    var foundLocation: Bool = false
    var locationStatus: NSString = "Not Started"
    var location: CLLocationCoordinate2D?
    var locationName: String?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        application.setStatusBarHidden(true, withAnimation: .None)
        initializeLocationManager()
        return true
    }

    func initializeLocationManager() { …
Run Code Online (Sandbox Code Playgroud)

coordinates cllocationmanager ios swift

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

在swift中使用CLLocationManager的位置类

我是iOS新手.我有一个应用程序,允许用户在不同的视图控制器中更新其位置.我试图最小化执行此操作的代码量,因此我将所有与位置相关的方法放在一个单独的类中,而不是复制方法来实现这一点.

import UIKit
import CoreLocation

class LocationUtil: NSObject, CLLocationManagerDelegate {
   let locationManager = CLLocationManager()

   func findUserLocation()->Void{
        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
        locationManager.requestWhenInUseAuthorization()
        locationManager.startUpdatingLocation()
    }
Run Code Online (Sandbox Code Playgroud)

从我的视图控制器我这样称呼这个类.

 override func viewDidLoad() {
        super.viewDidLoad()
        let locUtil = LocationUtil()
        locUtil.findUserLocation()

}
Run Code Online (Sandbox Code Playgroud)

但是,没有任何委托方法被调用.当我在视图控制器中直接使用相同的代码时,它工作正常.我究竟做错了什么?

cllocationmanager cllocation ios swift

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

CLLocationManager和tvOS - RequestWhenInUseAuthorization()没有提示

我似乎在让tvOS提示用户进行位置数据授权方面遇到了一些麻烦.我从iOS中复制并粘贴了工作代码,似乎没有提示用户.我使用下面列出的代码以及带字符串值的NSLocationWhenInUseUsageDescription键.我看到api的唯一区别是在iOS上它使用了startupdatinglocation()而在tvOS上它使用了requestLocation()(类似于watchOS)我已经逐步解决了问题,它实际上是在命令中请求USUseAuthorization()但是根本没有提示用户.

知道发生了什么事吗?

import UIKit
import CoreLocation
class ViewController: UIViewController {
  var locationManager = CLLocationManager()

  override func viewDidLoad() {
  super.viewDidLoad()

  locationManager.delegate = self
  locationManager.desiredAccuracy = kCLLocationAccuracyBest

  if CLLocationManager.locationServicesEnabled(){

    if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.NotDetermined{
      locationManager.requestWhenInUseAuthorization()
    }
    else if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedWhenInUse{
      locationManager.requestLocation()
    }

  }

}
Run Code Online (Sandbox Code Playgroud)

cllocationmanager swift tvos

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