1
[locationManager StarUpdatingLocation]
在我的情况下不起作用。我有一个NSOBject类,我有这样的方法。位置管理器不工作iphone应用
(void)findlocation
{
locationManager = [[CLLocationManager alloc] init] ;
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager startUpdatingLocation];
}
然后,我有委托方法
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
但是使用的NSLog语句我盘算了一下,startupdating定位方法犯规进入这个方法的LocationManager。 :(我打电话,在同一类的另一种方法的当前位置的方法,所以我会说[自currentLocation。任何帮助,将不胜感激。谢谢。
你在主线程或后台线程上运行你的'findlocation'方法吗? –
林不知道,但我认为它的主线。在xcode的底部它说线程1,所以我假设主线程?然而,基本上我有一个表视图控制器,它从名为location的类调用名为getlocationlist的方法,getlocationlist方法调用findlocation方法。我新来这个即时猜测主线程? – CodeGeek123
我可以发誓我刚才看到另一个答案,其中包括这个伟大的建议 - >如果你实现委托方法'[CLLocationManager locationManager:didFailWithError:]'是否被调用? –