2014-09-04 2 views
0

현재 위치 iOS 기반 요청 대화 상자 (아래 그림 참조)의 피드백을 기반으로보기 컨트롤러를 푸시하는 가장 좋은 방법은 무엇입니까?메소드를 실행하기 위해 현재 위치 대화 상자에 응답 할 때까지 기다리는 방법은 무엇입니까?

선택이 성공 -> 사용자를 흐름으로 보내거나 실패 -> 현재 위치를 허용해야하는 화면을 표시 한 후에 결정하려고합니다. 나는 버튼을 눌러 CLLocationManager를 할당하는 방법에서이 메서드를 호출으로까지 왔

:

- (void) confirmInfo { 


    BOOL locationAllowed = [CLLocationManager locationServicesEnabled]; 

    if (locationAllowed==NO) { 
     // Show the how-to viewcontroller 
    } else { 
     // Go to the next step onboarding 
    } 

} 

하지만 입력이 선택하는 대화 상자에서 다시 올 때까지 기다려야하는 방법을 모른다 어느 VC가 사용자를 보여줄 것인가.

enter image description here

답변

3

당신은 .. 위임 방법 사용자가 허용 또는 사용자가 허용 해달라고해도 가질 수 있으며 해당 응답에서 당신은 당신이 팝업을 밀어 계속할 수 있습니다.

다른 경우에도 흐름을 유지하기 위해 블록 기반 구조를 시도 할 수 있습니다. 다음 링크는 다음 대화 상자를 표시합니다 [self.locationManager startUpdatingLocations];를 호출 마지막으로, 그 위임에 컨트롤러를 설정, https://github.com/intuit/LocationManager 또는 https://github.com/FuerteInternational/FTLocationManager

INTULocationManager *locMgr = [INTULocationManager sharedInstance]; 
[locMgr requestLocationWithDesiredAccuracy:INTULocationAccuracyCity 
            timeout:10.0 
         delayUntilAuthorized:YES // This parameter is optional, defaults to NO if omitted 
            block:^(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status) { 
             if (status == INTULocationStatusSuccess) { 
              // Request succeeded, meaning achievedAccuracy is at least the requested accuracy, and 
              // currentLocation contains the device's current location. 
             } 
             else if (status == INTULocationStatusTimedOut) { 
              // Wasn't able to locate the user with the requested accuracy within the timeout interval. 
              // However, currentLocation contains the best location available (if any) as of right now, 
              // and achievedAccuracy has info on the accuracy/recency of the location in currentLocation. 
             } 
             else { 
              // An error occurred, more info is available by looking at the specific status returned. 
             } 
            }]; 
0

먼저 가하는 CLLocationManager을 만들 .. 당신을 도움이 될 수 있습니다.

그런 다음 사용자가 선택을 결정하기 위해 CLLocationManagerDelegate 방법을 사용하십시오

성공

,

– locationManager:didUpdateLocations:

가 호출됩니다. 그렇지 않으면

– locationManager:didFailWithError: