在iPhone模拟器上测试CoreLocation [英] Testing CoreLocation on iPhone Simulator

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

问题描述

更新:从iOS 5和Xcode 4.1现在可以测试模拟器中的位置,甚至定义路由。有关详情,请参阅 http://developer.apple.com



旧问题



是否还有在iPhone模拟器上测试CoreLocation?



require是能够自己设置位置,并让CoreLocation返回它。

解决方案

感谢您的反馈,



http://code.google.com/p/dlocation/rel =nofollow noreferrer> http://code.google.com/p/dlocation/



这是非常 凌乱,但我使用它会变得更好。



解决方案是子类 CLLocationManager 并定义一个新的委托 @protocol ,称为 DLocationManagerDelegate



它被设计为一个简单的替换 CLLocationManagerDelegate



当在设备上运行时,它将返回正常的数据,使用 CoreLocation ,但在模拟器中它将从文本文件(在DLocationManager.h文件中定义)读取纬度和经度。



我希望这有帮助,实现是在简单的一面,你必须 startUpdatingLocation stopUpdatingLocation 更新显示。



将非常感谢您的意见和反馈。


UPDATE: As of iOS 5 and Xcode 4.1 is is now possible to test location in the simulator and even define routes. See http://developer.apple.com for more details.

Legacy Question

Is there anyway to test CoreLocation on the iPhone Simulator?

All I require is to be able to set the location myself and have CoreLocation return it.

解决方案

Thanks for the great feedback, it has prompted me to find a robust solution.

All the code can be found here:

http://code.google.com/p/dlocation/

It is very messy but as I use it it will be become much better.

The solution was to subclass CLLocationManager and define a new delegate @protocol, called DLocationManagerDelegate.

It is designed to be a simple drop-in replacement for CLLocationManagerDelegate that compiles down to a very thin layer when deployed on an actual device.

When running on the device it will return data as normal using CoreLocation, but in the simulator it will read latitude and longitude from a text file (defined in the DLocationManager.h file).

I hope this helps, the implementation is on the simple side and you have to startUpdatingLocation and stopUpdatingLocation to update the display.

Comments and feedback will be gratefully received.

这篇关于在iPhone模拟器上测试CoreLocation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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