2012-10-24 2 views
0

CLLocationManager를 사용하는 동안 "현재 위치를 사용 하시겠습니까?"와 같은 하나의 알림을 요청하면서 현재 위치를 찾는 데 어려움을 겪고 있습니다. 두 가지 옵션 1.OK 2. 허용하지 마십시오. 그것은 어떤 아이디어를 가진 사람이 작업을 수행하고 이에 대한 관련, 다음 나에게 매우 유용 할 경우 ... ...이 두 개의 버튼에 대한 사용자 지정 작업을 작성할 수 있습니다CLLocationManager에 대한 버튼 동작 (현재 위치 팝업)

감사의 미리 ...

답변

0

이 같은 방법을 당신의 버튼에 첨부하거나의 viewDidLoad에서

-(void) showLocation 
{ 
    // put an alerview to ask user for allow/disallow 
} 

// alerView의 대리자 메서드를 호출, 예 버튼을 사용자의 현재 위치가

0

난 당신이 행동을 무시할 수 있다고 생각하지 않습니다 수 있도록 전년도 이 경고. 그러나 CLLocationManager의 대리자 메서드를 구현할 수 있습니다.

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error; 

사용자가 앱의 위치 서비스를 사용 설정했는지 여부를 확인할 수 있습니다. 여기

은 상기 방법

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { 

    [self.locationManager stopUpdatingLocation]; 
    switch([error code]) { 
     case kCLErrorDenied: 
      //User has not enabled location services for this app. 
      break; 
     case kCLErrorLocationUnknown: 
      //location could not be found 
      break; 
     default: 
      //some other issue 
      break; 
    } 

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"An error title" 
                message:@"An error message" 
                delegate:nil 
              cancelButtonTitle:@"OK" 
              otherButtonTitles:nil]; 
    [alert show]; 

} 
의 구현의 예