模拟`startMonitoringSignificantLocationChanges`的位置变化 [英] Simulating location changes for `startMonitoringSignificantLocationChanges`

查看:332
本文介绍了模拟`startMonitoringSignificantLocationChanges`的位置变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写iPhone应用程序并使用位置服务。我在 CLLocationManager 上使用 startMonitoringSignificantLocationChanges 方法。 (据我所知,这是针对低功耗,低精度的定位服务。)当我在iOS模拟器中构建并启动我的应用程序时,它获得了我的位置。但是,我想模拟初始修复之外的位置更新。

I am writing an iPhone app and using Location Services. I am using the startMonitoringSignificantLocationChanges method on CLLocationManager. (As I understand, this is for low power, low accuracy location services.) When I build and launch my app in iOS Simulator, it gets my location fine. However, I want to simulate updates to the location beyond the initial fix.

我注意到这两个选项:


  • iOS模拟器:调试>位置菜单

  • Xcode 4:产品>调试>模拟位置菜单

这两项工作都可以接受用于模拟初始修复。 (例如,从前者选择'Apple',或从后者选择'Moscow'。)但是,对其中任何一个的后续更改都不会在模拟应用中触发另一个位置更新。

Both of these work acceptably for simulating an initial fix. (For example, choose 'Apple' from the former, or 'Moscow' from the latter.) However, subsequent changes to either of these will NOT trigger another location update in the simulated app.

当使用 startMonitoringSignificantLocationChanges 时模拟位置发生变化时,我希望得到通知。 (当我使用 startUpdatingLocation 时,iOS模拟器生成一系列更新。)这样可以更轻松地测试启用位置的应用程序而无需考虑装置进入现场。

What I desire is to be notified when the simulated location changes when using startMonitoringSignificantLocationChanges. (iOS Simulator does generate a series of updates when I use startUpdatingLocation instead.) This makes it way easier to test location-enabled applications without taking the device out into the field.

两个问题:


  • 这两者有什么区别?

  • 如何使用iOS模拟器和/或Xcode 4模拟一系列位置变化?

干杯。

推荐答案

如果你想制作一个曲目,你可以用这样的航点创建一个GPX文件:

If you want to make a track, you can create a GPX file with waypoints like this:

<?xml version="1.0" encoding="UTF-8"?>
<gpx>
    <wpt lat="52.373" lon="4.871"></wpt>
    <wpt lat="52.374" lon="4.872"></wpt>
    <wpt lat="52.375" lon="4.871"></wpt>
</gpx>

将其保存为track.gpx。小心一开始就没有空格。

Save it as track.gpx. Be careful of having no whitespace at the start.

当你构建并运行时,Xcode底部有一个带有位置箭头的工具栏(类似于iPhone上的工具栏) )。这是模拟位置。单击此处并加载您的GPX文件。当您的应用程序在模拟器中运行时,蓝点应该移动。我不认为有一种方法可以控制时间,所以它每半秒左右更新一次位置。

When you Build and Run, there's a toolbar at the bottom of Xcode with a location arrow (similar to the one on iPhones). It's for "Simulate Location". Click there and load in your GPX file. When your app is running in the Simulator, the blue dot should move around. I don't think there's a way to control the timing, so it updates its location every half second or so.

我在模拟器菜单中看到的区别是您不能拥有自定义曲目,只能使用自定义曲目。我不知道为什么菜单选项不同,他们可能会在模拟器中为某个自定义轨道添加一个选项。

The difference I can see in the Simulator menu is that you can't have a custom track, only a custom point. I don't know why the menus options are different, they'll probably add an option for a custom track in the Simulator at some point.

这篇关于模拟`startMonitoringSignificantLocationChanges`的位置变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆