[英]Have issue in get current user's location with my app on ios 6
我的應用程序在iOS 5上運行良好,我獲得了普通用戶的位置信息。 但是在iOS 6上安裝我的應用程序時,我的應用程序無法獲取用戶的位置(我沒有彈出詢問權限位置,在位置服務中我沒有應用程序的圖標。其他應用程序,例如Instagram
和Path
在iOS 6的位置服務中具有該應用程序的圖標)。 當我在下面使用此代碼檢查此問題時, NSlog
顯示: Unable to determine, possibly not available
我不明白為什么會這樣。 我嘗試了其他應用程序,例如Instagram或Path。 我們仍然會獲得普通用戶的位置。 我在CLLocationManagerDelegate
研究了iOS 6更改方法委托,但我認為這不是原因,因為我的應用程序不要求獲得用戶位置的權限。
if ([CLLocationManager locationServicesEnabled]) {
NSLog(@"Location Services Enabled");
switch ([CLLocationManager authorizationStatus]) {
case kCLAuthorizationStatusAuthorized:
NSLog(@"We have access to location services");
break;
case kCLAuthorizationStatusDenied:
NSLog(@"Location services denied by user");
break;
case kCLAuthorizationStatusRestricted:
NSLog(@"Parental controls restrict location services");
break;
case kCLAuthorizationStatusNotDetermined:
NSLog(@"Unable to determine, possibly not available");
break;
default:
break;
}
}
else {
NSLog(@"Location Services Are Disabled");
}
我也有同樣的問題。 對於我的應用程序,這種情況之所以產生,是因為我檢查locationServices是否已啟用,並且僅在為true時才開始更新位置([self.locationManager startUpdatingLocation]。)
+ (BOOL)locationServicesEnabled {
if (([CLLocationManager locationServicesEnabled]) && ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized)) {
return YES;
} else {
return NO;
}
}
沒有檢查的[self.locationManager startUpdatingLocation]看起來不錯,但可能會產生其他問題。
我認為您的問題是,您只是檢查位置是否可用,而不使用它。 因此,iOS從未請求許可,因為未使用它。 您的支票運作良好!
使用教程像這一次 ,它會工作。 我也為我解決了!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.