2013-04-15 15 views
0

在模擬器中,我設置了debug-> location->自定義位置的經度和緯度。ios:調試自定義位置不起作用

然後,在代碼我有:

- (void)updateMap{ 
    MKCoordinateSpan span; 
    span.latitudeDelta = .6;//The amount of north-to-south distance (measured in degrees) to display on the map 
    span.longitudeDelta = .6;//The amount of east-to-west distance (measured in degrees) to display for the map region 

    MKCoordinateRegion region; 
    region.center = _ls.coordinate; 
    region.span = span; 
    [mapView setRegion:region animated:TRUE]; 
} 

在一個不同的文件I獲得@屬性(非原子,只讀)CLLocationCoordinate2D座標;

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ 

    //Get the latitude and longitude location 
    CLLocation *lastLocation = [locations lastObject]; 
    _latitude = [[NSString alloc] initWithFormat:@"%f", lastLocation.coordinate.latitude]; 
    _longitude = [[NSString alloc] initWithFormat:@"%f", lastLocation.coordinate.longitude]; 
    _coordinate = lastLocation.coordinate;//manager.location.coordinate; 
    } 

當我運行應用程序模擬器不斷顯示舊金山。任何想法爲什麼?

回答

1

得到它的工作:

(1)我不得不關閉Xcode和模擬器,並重新加載程序。現在它加載我的位置。:)

1

這是模擬器的默認位置。要模擬位置,請使用Xcode窗口中的下拉菜單來設置位置或「路徑」以模擬移動。

+0

這個下拉是哪裏?我使用Simulator Debug下拉菜單輸入了一個位置的經度和緯度,但我仍舊得到舊金山。 – wwjdm

+0

它是在Xcode中,在調試輸出窗口上方看到:http://stackoverflow.com/questions/214416/set-the-location-in-iphone-simulator – tcarlander