[英]didUpdateLocations: method not called on device running iOS 7
我面臨一個奇怪的問題。 我正在使用- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
獲取設備位置。 在simulator (iOS 6 and iOS 7)
和iPhone 4S running iOS 6.1.3
。 當我將iPhone 4 running iOS 7
連接到系統並安裝該應用程序時,它也可以正常工作,但是當我拔出設備並重新運行該應用程序時,此方法不會被調用,並且我也無法獲取位置。 我該如何克服這個問題?
您是如何設置位置管理器的?
您的界面中是否有:
@interface ViewController : UIViewController <CLLocationManagerDelegate> {
@property (strong, nonatomic) CLLocationManager *locationManager;
}
然后在viewDidLoad中實現:
// setup location manager
if ([CLLocationManager locationServicesEnabled]) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.delegate = self;
[_locationManager startUpdatingLocation];
}
並且您需要實現委托:
locationManager:didUpdateLocations:
注意:在IOS 7中
locationManager:didUpdateToLocation:fromLocation
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.