2014-09-19 50 views

回答

0

解決方法是執行CLLocationManagerDelegate方法中的操作;

// Location Manager Delegate Methods 
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations 

該方法在用戶授​​予使用位置服務權限後被調用。或者如果用戶已經授予訪問權限,那麼它將自動被調用。如果你只想調用某種方法,你可以這樣做:

// Location Manager Delegate Methods 
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ 
    CLLocation *location = [locations lastObject]; 
    if(location !=nil){ 
    //we got a location 
    //<YOUR METHOD GOES HERE> 
    [manager stopUpdatingLocation]; 



    } 
} 
相關問題