【发布时间】:2015-07-31 05:48:34
【问题描述】:
无法从我的代码中获取当前位置:
(IBAction)getdetails:(id)sender {
manager.delegate = self;
manager.desiredAccuracy = kCLLocationAccuracyBest;
[manager startUpdatingLocation];
}
#pragma mark - CLLocationManagerDelegate
(void)locationmanager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
_latitudelabel.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude];
_latitudelabel.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude];
}
【问题讨论】:
-
请解决这个问题..我还添加了 tw 框架工作核心位置,mapkit..
-
请正确格式化您的问题。使用
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations。 Reference -
请用您面临的问题更新您的问题,并查看其格式是否正确,以便希望提供帮助的人可以这样做。
标签: ios