使用模拟器测试自定义位置 [英] Testing custom location with simulator

查看:151
本文介绍了使用模拟器测试自定义位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是花了最后一个小时来搜索-认为必须要回答-并没有找到太多,所以我在这里问。

I just spent the last hour searching - thinking that there has to be an answer - and didn't find much, so I'm asking here.

我正在尝试获取示例应用程序区域,以通过模拟器触发进入和/或退出区域的更新。我熟悉通过调试>位置>自定义位置设置特定的纬度和经度,但这似乎没什么用,尽管它在LocateMe示例应用程序中似乎可以正常工作。此时,我不知道问题是iOS模拟器的局限性还是示例应用程序处理区域检测的方式(我对iOS还是很陌生)。

I'm trying to get the sample app Regions to trigger enter and/or exit regions updates via the simulator. I'm familiar with setting a specific latitude and longitude with Debug > Location > Custom Location but that doesn't seem to do much, although it does seem to work in the LocateMe sample app. At this point I don't know if the problem is a limitation of the iOS Simulator or of the way the sample app handles region detection (I'm still rather new to iOS).

我遇到了 FTLocationSimulator 但我想知道这是否会有所帮助(特别是因为它似乎模仿了通过模拟器设置自定义位置的功能)。

I've come across the FTLocationSimulator but I wonder if that's going to help (especially since it seems to mimic the ability to set Custom Locations via the Simulator).

似乎也没有有关iOS模拟器设置自定义位置的功能的Apple文档,很多。

There also doesn't seem to be much in terms of Apple documentation regarding the iOS Simulators ability to set Custom Locations.

推荐答案

将GPX文件添加到您的项目并添加它的航路点。当您的应用程序在模拟下运行时,请使用XCode的模拟位置功能(位于底部的调试栏上的小箭头),然后选择您的GPX文件。然后XCode将开始为您的应用程序提供坐标。

Add a GPX file to your project and add waypoints to it. When your app is running under simulation use the Simulate Location feature of XCode (the little way-arrow sitting on the debug bar at the bottom) and choose your GPX file. XCode will then start supplying coordinates to your app.

示例GPX文件内容:

<?xml version="1.0"?>
<gpx>
  <wpt lat='33.749272' lon='-84.388261'><name>Atlanta, Georgia</name></wpt>
  <wpt lat='42.7335'   lon='-84.5467'><name>Lansing, Michigan</name></wpt>
  <wpt lat='32.361667' lon='-86.279167'><name>Montgomery, Alabama</name></wpt>
  <wpt lat='38.576667' lon='-92.173611'><name>Jefferson City, Missouri</name></wpt>
  <wpt lat='41.590833' lon='-93.620833'><name>Des Moines, Iowa</name></wpt>
</gpx>

请注意,模拟器会连接两个航点之间的点(在上面的示例中,它将生成位于佐治亚州亚特兰大市与密歇根州兰辛市之间的直线上。

Note that the simulator will 'connect the dots' between two waypoints (in the example above it will generate locations along a line between Atlanta, Georgia and Lansing, Michigan.

这篇关于使用模拟器测试自定义位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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