why Delegate Methods for CurrentLotion(CLLocationManager) is not called in iOS4.0?
I am using iPhone sdk 4.0.I have used below code for taking Current location but it's delegate methods is not called Automatically...My code is given below:
in .hfile
i have import
CoreLocation/CoreLocation.h
also delegate
CLLocationManagerDelegate
CLLocationManager *locationManager;
in .mfile
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
[locationManager startUpdatingLocation];
but i don't get the current location for that......My Delegate Method is which is not called:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocati开发者_如何学Pythonon
{
}
Your code looks correct to me. Did you also tried to run this code on a real iPhone? Simulator is not always responding to location manager updates. There is also another important delegate method you should add to your .m file:
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
This one will be called in case something goes wrong. For instance the location manager failed to localize your iPhone.
I encounter same problem. All the code looks ok but the delegate method was not called.
I closed the simulator completely. When I rerun the app, delegate method was called.
精彩评论