현재 위치를 가져올 수 없습니다. 다른 곳에서 내 앱을 실행하면 앱에서 마지막 위치를 얻을 수 있습니다. 그러나 나는 마지막 위치를 원하지 않습니다. 앱을 닫고 다시 시작하면 앱에서 현재 위치를 가져올 수 있습니다. 신청서를 처음 열어도 현재 위치는 어떻게 알 수 있습니까?iOS에서 현재 위치를 얻는 방법은 무엇입니까?
- (void)viewDidLoad
{
[super viewDidLoad];
[locationManager startUpdatingLocation];
self.mapView.delegate = self;
[self.mapView setShowsUserLocation:YES];
locationManager.delegate=self;
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate=self;
locationManager.desiredAccuracy=kCLLocationAccuracyBest;
locationManager.distanceFilter=kCLDistanceFilterNone;
location = [locationManager location];
CLLocationCoordinate2D coord;
coord.longitude = location.coordinate.longitude;
coord.latitude = location.coordinate.latitude;
lat = coord.latitude;
longt = coord.longitude;
}
[을 locationManager를 startUpdatingLocation]; 델리게이트를 설정 한 후이 줄을 넣으십시오. – Rajneesh071