- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有关于显着变化位置服务的问题。
Apple 文档说“无论您使用标准定位服务还是重大更改定位服务来获取定位事件,您接收这些事件的方式都是相同的。”
但是在“显着变化的位置服务”的情况下,我无法获得任何回调我得到了“标准位置服务”的情况请让我知道是否有人有任何意见?
最佳答案
startUpdatingLocation
在第一次调用时更新位置,然后在距离过滤器值超过时更新位置。
但是 startMonitoringSignificantLocationChanges
位置发生重大变化时。
请查看CLLocationManager了解详情。
startUpdatingLocation
Starts the generation of updates that report the user’s current location.
- (void)startUpdatingLocation Discussion
This method returns immediately. Calling this method causes the location manager to obtain an initial location fix (which may take several seconds) and notify your delegate by calling its locationManager:didUpdateLocations: method. (In iOS 5 and earlier, the location manager calls the locationManager:didUpdateToLocation:fromLocation: method instead.) After that, the receiver generates update events primarily when the value in the distanceFilter property is exceeded. Updates may be delivered in other situations though. For example, the receiver may send another notification if the hardware gathers a more accurate location reading.
Calling this method several times in succession does not automatically result in new events being generated. Calling stopUpdatingLocation in between, however, does cause a new initial event to be sent the next time you call this method.
If you start this service and your application is suspended, the system stops the delivery of events until your application starts running again (either in the foreground or background). If your application is terminated, the delivery of new location events stops altogether. Therefore, if your application needs to receive location events while in the background, it must include the UIBackgroundModes key (with the location value) in its Info.plist file.
In addition to your delegate object implementing the locationManager:didUpdateLocations: method, it should also implement the locationManager:didFailWithError: method to respond to potential errors.
startMonitoringSignificantLocationChanges
Starts the generation of updates based on significant location changes.
- (void)startMonitoringSignificantLocationChanges Discussion
This method initiates the delivery of location events asynchronously, returning shortly after you call it. Location events are delivered to your delegate’s locationManager:didUpdateLocations: method. The first event to be delivered is usually the most recently cached location event (if any) but may be a newer event in some circumstances. Obtaining a current location fix may take several additional seconds, so be sure to check the timestamps on the location events in your delegate method.
After returning a current location fix, the receiver generates update events only when a significant change in the user’s location is detected. For example, it might generate a new event when the device becomes associated with a different cell tower. It does not rely on the value in the distanceFilter property to generate events. Calling this method several times in succession does not automatically result in new events being generated. Calling stopMonitoringSignificantLocationChanges in between, however, does cause a new initial event to be sent the next time you call this method.
If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options dictionary passed to the locationManager:didUpdateLocations: method of your application delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your application was launched because of a location event. Upon relaunch, you must still configure a location manager object and call this method to continue receiving location events. When you restart location services, the current event is delivered to your delegate immediately. In addition, the location property of your location manager object is populated with the most recent location object even before you start location services.
In addition to your delegate object implementing the locationManager:didUpdateLocations: method, it should also implement the locationManager:didFailWithError: method to respond to potential errors.
Note: Apps can expect a notification as soon as the device moves 500 meters or more from its previous notification. It should not expect notifications more frequently than once every five minutes. If the device is able to retrieve data from the network, the location manager is much more likely to deliver notifications in a timely manner.
关于iphone - StartUpdatingLocation 与重大更改位置服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14709082/
我的问题很简单: 这些可以吗: manager.delegate = self; [manager startUpdatingLocation]; return self; 作为 -init 方法的最
我创建了一个方法来检查授权是否正确,但是除此之外,即使授权正确,也不意味着它可以检索位置。我试图在 didFailWithError 中检查它,但它似乎被调用了两次,这使得很难发出任何类型的错误消息这
我一直在尝试获取位置坐标。在我调用 [locationManager startUpdatingLocation]; 之后没有任何反应。 它从不调用 - (void)locationManager:(
我有关于显着变化位置服务的问题。 Apple 文档说“无论您使用标准定位服务还是重大更改定位服务来获取定位事件,您接收这些事件的方式都是相同的。” 但是在“显着变化的位置服务”的情况下,我无法获得任何
对于为什么应该使用startUpdatingLocation来定位信标,我没有令人信服的答案。在后台监视/定位信标或在用户已经在区域中并开始监视信标时获取通知是否需要?出现在帖子中,说这实际上会增加电
我有一个需要在后台连续更新GPS的应用程序。我已将其命名为startUpdatingLocation,并设置了“用于位置更新的应用程序注册”,并且得到了大约15分钟的修复,然后该应用程序停止获取更新。
我注意到,在我的应用程序中,当我调用 startUpdatingLocation 时,我的 UI 会短暂锁定,同时我假设设备正在收集位置数据。这是典型的吗?有什么方法可以限制这种情况吗?这就是我的代码
我有一个特定的用例,我希望能够在应用程序已在后台时启动位置更新。具体来说,我希望能够按下我的 Pebble watch 应用程序上的一个按钮,这会导致我的配套 iOS 应用程序开始位置更新。 仅当 i
我正在尝试使用 CLLocation。每次我尝试调用 startUpdatingLocation() 方法时,当前纬度和经度的值始终为零。我在 viewDidLoad() 函数中包含了 locatio
我需要知道我是否靠近我的应用程序中保存的地理位置,范围从10 米 到500 米 在后台。我使用了 startMonitoringForSignificantLocationChange 但我没有得到准
{ ... locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; l
所以现在我至少得到了以下代码的回调...... - (void)viewDidLoad { [super viewDidLoad]; mapView=[[MKMapView alloc] initWi
我正在尝试更改 MapView 的初始缩放位置。如果 myLocation == false,我希望初始位置为 (35,35),如果为 true,则获取当前位置。但是 startUpdatingLoc
我创建了一个应用程序 (Swift 4.0),当它接近 iBeacon 时,它会通过 startUpdatingLocation() 启动本地化。一切都很完美,无论是在前台、后台还是被杀死的应用程序。
这个问题在这里已经有了答案: StartUpdateLocations in Background, didUpdatingToLocation only called 10-20 times (
我正在尝试编写一个简单的地理定位应用程序来查找用户在 iOS 中的位置。当用户按下按钮时,会找到并显示用户的位置,并且应该在触发 startUpdatingLocation 时更改。但是 startU
我正在尝试使用 CLLocationManager 获取用户的当前位置。一切正常,但是在应用程序查找位置时有一点延迟,我需要等待它完成才能允许用户发送它。 [locationManager start
我正在创建需要在特定时间在后台唤醒的应用。 我试过了: UILocalNotification:但我不想使用 UILocalNotification,因为它需要用户交互才能点击通知,而且只有应用程序会
我一直在关注这个教程http://www.devfright.com/ios-6-core-location-tutorial/将位置服务添加到我的 ios 应用程序。我在我的 TestFileVie
override func awakeWithContext(context: AnyObject?) { super.awakeWithContext(context) // Con
我是一名优秀的程序员,十分优秀!