2012-04-28 13 views
6

私はuser.canの現在の場所を見つける必要があるアプリをやっています。私はCLLocationmanagerを使ってiOS 5シミュレータでユーザの現在の場所を取得していますか?シミュレータの現在の位置

答えて

8

Xcodeの - 編集スキーム - 実行you.app - オプション

チェックがXcodeで

Add GPX File to Project 

形式like this

-4
- (void)viewDidLoad{ 
    [super viewDidLoad]; 
    self.title = @"MapView"; 
    self.navigationController.navigationBarHidden = NO; 
    locationManager = [[CLLocationManager alloc] init]; 
    locationManager.delegate = self; 
    locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move 
    locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m 
    [locationManager startUpdatingLocation]; 
} 

- (void) loadPin { 
    iCodeBlogAnnotation *appleStore1; 
    CLLocationCoordinate2D workingCoordinate; 
    workingCoordinate.latitude = [latitude doubleValue]; 
    workingCoordinate.longitude = [longitude doubleValue]; 
    appleStore1 = [[iCodeBlogAnnotation alloc] initWithCoordinate:workingCoordinate]; 
    [appleStore1 setTitle:[NSString stringWithFormat:@"Default Point"]]; 

    //[appleStore1 setSubtitle:[NSString stringWithFormat:@"Distance %.2f Miles",miles]]; 
    [appleStore1 setAnnotationType:iCodeBlogAnnotationTypeEDU]; 
    [mapView addAnnotation:appleStore1]; 
    [(MKMapView*)self.mapView selectAnnotation:appleStore1 animated:NO]; 
    MKCoordinateRegion region; 
    region.center.latitude = [latitude doubleValue]; 
    region.center.longitude = [longitude doubleValue]; 
    region.span.latitudeDelta = .5; 
    region.span.longitudeDelta = .5; 
    [mapView setRegion:region animated:YES]; 
} 

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
    latitude = [[NSString alloc] initWithFormat:@"%f", newLocation.coordinate.latitude]; 
    longitude = [[NSString alloc] initWithFormat:@"%f", newLocation.coordinate.longitude]; 
    [locationManager stopUpdatingLocation]; 
    if (latitude > 0) { 
     [self loadPin]; 
    } 
} 
+0

私はあなたの答えビットをフォーマットし、あなたが気にしない願っています。しかし、あなたの答えを見直した後:これはOPの質問に関連していると確信していますか? –

7

"デフォルトの場所" を選択し、場所シミュレーションを許可します、コンソール上の小さなボタンを使用してシミュレートする場所を選択できます。

enter image description here

関連する問題