I am facing a strange problem. I am using - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
to get device location. It is working fine on simulator (iOS 6 and iOS 7)
and iPhone 4S running iOS 6.1.3
. It is also working fine when I connect iPhone 4 running iOS 7
to system and install the app but as soon as I unplug the device and re-run the app, this method doesn't get called and I don't get the location. How can I overcome this issue?
How did you setup you location Manager?
Do you have in your interface:
@interface ViewController : UIViewController <CLLocationManagerDelegate> {
@property (strong, nonatomic) CLLocationManager *locationManager;
}
Then in implementation in viewDidLoad:
// setup location manager
if ([CLLocationManager locationServicesEnabled]) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.delegate = self;
[_locationManager startUpdatingLocation];
}
And you need to implement the delegate:
locationManager:didUpdateLocations:
Be careful: In IOS 7
locationManager:didUpdateToLocation:fromLocation
is deprecated. Apple link to CLLocationManagerDelegate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.