我在我的應用程序上使用MKMapView。我需要在模擬器上顯示當前位置。
是否可能。在模擬器上顯示當前位置。如何在MKMapView上顯示當前位置
回答
在模擬器中,用戶的當前位置始終位於加利福尼亞州的庫比蒂諾。
如果您使用Interface Builder來添加地圖視圖,只需選中地圖視圖的屬性檢查器中的「顯示用戶位置」複選框。 (選擇地圖視圖並鍵入command-1
以顯示屬性檢查器。)
如果以編程方式添加或操作地圖視圖,請將地圖視圖的showsUserLocation
屬性設置爲YES
。
更新:事實證明,這是可能的,只是沒有使用內置的地圖視圖功能,它並不總是工作。
最近版本的SDK(必須在Snow Leopard上運行)可以使用CLLocationManager獲取運行模擬器的機器的位置。然後,您可以使用此位置創建註釋以在地圖視圖上顯示。它不會像內置的「用戶位置指示器」(至少不是沒有一些工作),但會顯示用戶的當前位置。
請參閱this post以瞭解何時此技術無法使用的詳細信息。
有關使用CLLocationManager和CLLocationManagerDelegate的示例代碼,請參見CLLocationManager documentation的「相關示例代碼」部分,然後在地圖視圖上顯示用戶的位置。
self.mapView.delegate = self;
self.mapView.showsUserLocation = YES;
這將顯示當前位置MkMapview
。
如果您正在使用Interface Builder,在屬性檢查器中,我們有一個選項Behaviour
,其中有一個選項Show User Location
,用於檢查該選項是否也執行相同操作。
如果你不能在模擬器上看到,
- 公開賽在模擬器中的應用。
- 從菜單欄選擇調試 - >位置 - >(如果選擇「無」選項,將其更改爲「自定義位置」)並設置位置。
隨着CLLocationManager
我們也可以得到當前位置, 進口Corelocation
框架項目
在.h
文件
#import <CoreLocation/CoreLocation.h>
@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic, strong) CLLocation* currentLocation;
在.m
文件
if ([CLLocationManager locationServicesEnabled])
{
if (self.locationManager == nil)
{
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.distanceFilter = kDistanceFilter; //kCLDistanceFilterNone// kDistanceFilter;
}
[self.locationManager startUpdatingLocation];
}
委託函數:
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
self.currentLocation = [locations lastObject];
// here we get the current location
}
希望這個答案可以幫到你。
無論是iOS 6,6.1還是iOS 7,模擬器都不會顯示用戶當前的位置。要模擬位置,您可以看到here。如果你想顯示用戶的當前位置,然後運行你的應用程序在設備或更改模擬器設置 - 從模擬器菜單
選擇調試>位置>自定義地點....
- 1. MKMapview顯示當前位置錯誤
- 2. mkMapview上顯示當前位置的詳細信息?
- 3. 如何使用MKMapView顯示從當前位置到neares位置的方向
- 4. 如何設置mkmapview以顯示距離我當前位置100米的距離?
- 5. MKMapView顯示爲自定義引腳的當前位置
- 6. android gps如何顯示當前位置
- 7. 如何在mkmapview上顯示多個位置點
- 8. 顯示MKMapView以一次顯示多個註釋和當前用戶位置
- 9. 如何在iOS的tableViewCell上顯示當前位置
- 10. 如何在MapView上每10秒顯示一次當前位置?
- 11. 在當前位置和單獨位置放置地標mkmapview
- 12. 加載當前位置的MKMapView
- 13. 如何在MKMapView中居中當前位置?
- 14. 獲取用戶在MKMapView上的當前位置
- 15. MKMapView不顯示當前位置,或者更確切地說,任何位置(在模擬器中)
- 16. 如何在MKMapView上顯示文本
- 17. 根據用戶的位置在MKMapView上顯示註釋
- 18. 如何在osmdroid中顯示當前位置指針?
- 19. 如何在文本框中顯示當前位置地址?
- 20. 如何在android mapview中精確顯示當前位置?
- 21. 如何在Android中顯示谷歌當前位置圖標?
- 22. 如何在Google地圖中顯示設備的當前位置?
- 23. 顯示當前用戶位置?
- 24. 在NSTextView上顯示當前光標位置的滾動內容
- 25. Android:在地圖上顯示和移動當前位置
- 26. Sencha touch 2 - 在地圖上顯示當前位置
- 27. 在Android屏幕的上半部分顯示當前位置
- 28. 在Google地圖上顯示當前位置附近的多個位置
- 29. 在Android的谷歌地圖上顯示當前位置和其他位置
- 30. 如何在xcode上使用FLICKR API來顯示當前位置的圖像?
+1 ---- OK我收回我的答案,並高興地知道是否有可能...... 我新的事情要做.... 謝謝... – Saawan 2010-10-20 06:15:26
請給我看看我的問題,並建議的東西----和http: //stackoverflow.com/questions/3966796/are-there-any-libraries-or-examples-of-how-to-handle-ofx-on-the-iphone – Saawan 2010-10-20 06:20:25