[英]Location Services in iOS 6 not working
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
static int i=0;
if([self getCurrentLocation]==nil){
i++;
if(i>3){
[[self locationManager] stopUpdatingLocation];
useMyLocation = NO;
[self locationUpdated];
}
}else{
[self locationUpdated];
}
}
- (void)alertView:(UIAlertView *)anAlertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex==1){
self.useMyLocation = YES;
[[self locationManager] startUpdatingLocation];
}else{ // buttonIndex==0
self.useMyLocation = NO;
[self locationUpdated];
}
}
这是ios 4和5中的有效代码。我的问题是,我无法在ios 6中获得工作位置。该应用程序甚至没有征求用户的许可。 读完之后,这是我到目前为止尝试过的:
CFBundleDisplayName解决方案。 我的plist中已经有CFBundleDisplayName。 我尝试将其删除并再次添加-不行。
将位置管理器的属性pausesLocationUpdatesAutomatically自动设置为NO,如下所示:
...
- (CLLocationManager *)locationManager{
if (locationManager != nil){
return locationManager;
}
CLLocationManager *tmp = [[CLLocationManager alloc] init];
tmp.pausesLocationUpdatesAutomatically = NO; //!@#
[self setLocationManager:tmp];
[tmp release];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager setDelegate:self];
return locationManager;
}
我还阅读了有关locationManager:didUpdateLocations:
,我不知道如何在代码中实现它,我也不知道这是否是解决方案。
您是否曾经启动过位置管理器?
[locationManager startUpdatingLocation];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.