2009-10-31 5 views
0

내 위치를 얻으려면이 방법을 사용하고 있습니다. 실제 장치에 대한 시뮬레이터에서 작동합니다. 매우 빠릅니다. 실행 속도를 줄이십시오. 또한 장치를 시뮬레이션하지 않은 경우 오류를 한 번만 표시하는 방법 또한 사용자가 현재 위치 사용을 거부 한 경우 여기 methods-- CLLocationManagerDelegate 프로토콜에서기기에 iphone SDK를 사용하여 SIM 카드가 없는지 어떻게 감지합니까?

-(void)GetCurrentLocation { 
// Create the location manager if this object does not 
// already have one. 
if (nil == locationManager) 
    locationManager = [[CLLocationManager alloc] init]; 
if (locationManager.locationServicesEnabled == NO) { 
    UIAlertView *servicesDisabledAlert = [[UIAlertView alloc] initWithTitle:@"Location Services Disabled" message:@"You currently have all location services for this device disabled. If you proceed, you will be asked to confirm whether location services should be reenabled." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
    [servicesDisabledAlert show]; 
    [servicesDisabledAlert release]; 
[locationManager release]; 
    }  
else{ 
    locationManager.delegate = self; 
    locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; 
    [btnGPSFix setHidden:NO]; 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:1.0];// Sub. duration 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:btnGPSFix cache:YES]; 
    [self showMsg:@"Getting a GPS fix..." WithDelay:7]; 
    [UIView commitAnimations]; 
    [locationManager startUpdatingLocation]; 
} 
} 

// 위임 방법입니다. 여기

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
// If it's a relatively recent event, turn off updates to save power 
NSDate* eventDate = newLocation.timestamp; 
    NSTimeInterval howRecent = [eventDate timeIntervalSinceNow]; 
if (abs(howRecent) < 5.0) { 
    [manager stopUpdatingLocation]; 
    printf("latitude %+.6f, longitude %+.6f\n",newLocation.coordinate.latitude,newLocation.coordinate.longitude); 
    LatitudeData = [[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.latitude]; 
    LongitudeData = [[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.longitude]; 
[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1.0];// Sub. duration 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:btnGPSFix cache:YES]; 
    [self showMsg:@"GPS Acquired" WithDelay:4]; 
    [UIView commitAnimations]; 
    [self insertIntoDataBase]; 
    } 
    // else skip the event and process the next one. 
} 

내 [자기 showMsg : WithDelay :]는 방법 여기

- (void)showMsg:(NSString*)Message WithDelay:(int)delay 
{ 
CGRect frame = CGRectMake(30, 366, 259, 37); 
[btnGPSFix setTitle:Message forState:UIControlStateNormal]; 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:1.0]; 
frame.origin.y = 366; 
btnGPSFix.frame = frame; 
[UIView commitAnimations]; 
// Hide the view after the requested delay 
[self performSelector:@selector(HideGpsFixButton) withObject:nil afterDelay:delay]; 
} 

내가이 GPS 위치를 점점 보여줍니다 장치를 체크 한

- (void)HideGpsFixButton 
{ 
// Slide the view down off screen 
CGRect frame = CGRectMake(30, 366, 259, 37); 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:1.0]; 
frame.origin.y = 480; 
btnGPSFix.frame = frame; 
[UIView commitAnimations]; 

} 

HideGpsFixButton 방법입니다 message.device에는 sim inserted.i가 없습니다. 귀하의 장치에 sim이 삽입되지 않았거나 사용자가 위치 서비스를 허용하지 않는다는 하나의 메시지 만 표시하려고합니다. 그런 다음 메시지 위치 서비스가 사용자에 의해 비활성화되어 있음을 보여줍니다. 도움을 주시면 감사하겠습니다.

답변

1

당신은 할 수 없습니다. 애플은 sim, 셀 라디오, 당신이있는 네트워크 등의 정보 정보를 공개하지 않습니다. 당신이이 기능을 원한다면, 애플이 당신이 왜 필요한지 설명하는 버그가 있어야합니다.

관련 문제