问题描述
所以,
我正在尝试将我的应用移植到iPad。
我正在使用CoreLocation。
i'm trying to port my app to iPad.I'm using CoreLocation.
Apple说iPad确实有
Apple says the iPad does have
Location:
Wi-Fi
Digital compass
Assisted GPS (Wi-Fi + 3G model)
Cellular (Wi-Fi + 3G model)
因此应该可以获得我的ipad(至少3g模型)的位置,大约3km半径将是enought。
so it should be possible to get the position of my ipad (at least with 3g model) about 3km radius would be enought.
但它在模拟器(3.2 ipad)中无效(在模拟器中运行3.1.3模拟我cupertino)。
but it doesnt work in simulator (3.2 ipad) (running 3.1.3 in simulator simulates me cupertino).
有没有办法在模拟器中获得位置(3.2 ipad)?
i住在德国,这里ipad尚未发布,所以我无法在我的设备上测试。
is there a way to get the position in simulator (3.2 ipad) ?i live in germany and here the ipad isnt released yet, so i cannot test it on my device.
谢谢!
这就是我如何获得我的连接
thats how i'm trying to get my connection
locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
locationManager.delegate = self;
[locationManager startUpdatingLocation];
并始终在3.2 locationManager:(CLLocationManager *)manager didFailWithError:(NSError) *)错误
被调用。不在3.1.3
and always on 3.2 locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
gets called. not on 3.1.3
错误对象如下所示:
Error Domain=kCLErrorDomain Code=0 "Operation could not be completed. (kCLErrorDomain error 0.)"
编辑
所以我处理了这样的事情:
edit
so i handled it something like this:
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
#ifdef TARGET_IPHONE_SIMULATOR
// Cupertino
CLLocation *simulatorLocation = [[CLLocation alloc] initWithLatitude:37.33168900 longitude:-122.03073100];
[self locationManager:locationManager didUpdateToLocation:simulatorLocation fromLocation:nil];
[simulatorLocation release];
#else
[[NSNotificationCenter defaultCenter] postNotificationName:@"ErrorNotification" object:NSLocalizedString(@"GPS-coordinates could not be detected",@"")];
#endif
}
是非常凌乱,但有效。
edit2:尝试启用您的机场,这也可以解决问题!!
edit2: try enabling your Airport, this could also solve the problem!!
推荐答案
是的,请参阅这有几个很好的答案。
Yes, see this question which has several good answers to this.
编辑 - 我最终决定编写自己的CLLocationManager模拟器,以便在iPhone模拟器上进行测试。如果您想使用它,它位于。
EDIT - I eventually decided to write my own CLLocationManager simulator for testing on the iPhone simulator. It's located on github here if you want to use it.
这篇关于iPhone模拟器3.2(iPad)中的核心位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!