2011-09-23 61 views
1

我嘗試顯示在地圖上的位置,這裏是代碼:問題與CLLocationManager在iPhone模擬器

locationManager = [[CLLocationManager alloc] init]; 
locationManager.distanceFilter = kCLDistanceFilterNone; 
locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
[locationManager.location initWithLatitude:latitude longitude: longitude]; 
NSLog(@"%f", [selectedBuilding.latitude doubleValue]); 
[locationManager startUpdatingLocation]; 

但是,不管是什麼座標我提供,藍點始終位於加州,這似乎在默認行爲,有什麼額外的我需要做的?謝謝。

+0

你是模擬器嗎?此外,您不應將自己的位置設置爲LocationManager屬性,因爲它是隻讀的 – mja

+0

是的,我處於模擬器中,並且已啓用IB中的「顯示用戶位置」。 – Michael

+0

看看這裏http://stackoverflow.com/questions/802156/testing-corelocation-on-iphone-simulator – mja

回答

1

在模擬器中CLLocationManager總是在蘋果的總部。它來自CLLocation類參考:
座標
地理座標信息。 (只讀)

@property(只讀,非原子)CLLocationCoordinate2D座標
討論
當在模擬器運行,核心定位分配一組固定的座標值,以該屬性的。您必須在基於iPhone OS的設備上運行您的應用程序以獲取真實的位置值。

可用性
適用於iPhone OS 2.0及更高版本。

CLLocation.h

+0

謝謝,我沒有意識到它是隻讀的。 – Michael