모든 위치의 위치 속성을 가져올 수있는 앱을 개발하려고합니다. 이위치 관리자 대리인이 iOS objective-c에서 호출되지 않았습니다.
@interface ViewController : UIViewController <CLLocationManagerDelegate, CBCentralManagerDelegate, AVAudioRecorderDelegate, AVAudioPlayerDelegate>
{
CLLocationManager *locationManager;
CMMotionManager *motionManager;
}
@property(nonatomic, strong) CLLocationManager *locationManager;
@end
이 ViewController.m이
locationManager = [[CLLocationManager alloc] init];
- (void)startAllDataRec
{
[self getLocation];
}
- (void)getLocation
{
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
[locationManager requestAlwaysAuthorization];
}
//Checking authorization status
if (![CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied)
{
NSLog(@"you are denied a permission");
}
else
{
//Location Services Enabled, let's start location updates
[locationManager startUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
mLat = currentLocation.coordinate.latitude;
mLon = currentLocation.coordinate.longitude;
mSpeed = currentLocation.speed;
mAlt = currentLocation.altitude;
mCourse = currentLocation.course;
NSLog(@"lat lon speed alt course = %f, %f, %f, %f, %f", mLat, mLon, mSpeed, mAlt, mCourse);
dispatch_async(dispatch_get_main_queue(), ^{
self.speedLbl.text = [NSString stringWithFormat:@"%f", mSpeed];
});
}
else{NSLog(@"current location is nil");};
}
이 문제가 대리자에서 호출되지 않고있다 장치의 위치
ViewController.h를 얻기 위해 지금 내가 가지고있는 코드입니다 언제든지 액세스 권한을 부여 할 때조차도 트리거되지 않음 누락 된 항목이 있습니까? 먼저 호출해야합니까?
add locationManager = [[CLLocationManager alloc] init]; getLocation 메소드에서 getLocation을 호출하고 viewwillappear에서 getLocation을 호출하십시오. 위치를 확인하기 전에 사용자 권한을 요청해야합니다. 나는이 누구도 보지 못했다. Google CLLocationManager 자습서. 그들 중 많은 사람들이 밖에 있습니다. –
CLLocations에 대한 많은 자습서를 확인했는데 사용자 권한 문제가 표시되지 않았습니다. 하지만 무슨 뜻인지 알 겠어. 내가 뭘 할 수 있는지 보려고 노력할거야. – Nik391
나는 내 질문을 업데이트하고 인증 액세스를 부여했지만 여전히 문제는 동일합니다 – Nik391