簡體   English   中英

在運行時設置位置模擬器City / GPX

[英]Set location simulator City/GPX during Runtime

有沒有一種方法可以在運行時以編程方式更改位置模擬器城市? 例如,這將允許測試模擬倫敦或東京。

下圖顯示了如何手動切換位置(GPX文件)。 如何在應用程序運行時以編程方式實現此結果?

在此輸入圖像描述

設置位置的替代方法是通過調用“CLLocationManager”類的“位置”。 在obj-c中,

+(void) load {
   // replace 'location' with 'custom_location' method
 }

然后通過簡單地更改“kMockedLatitude”和“kMockedLongitude”變量,使用您想要設置的任何位置實現custom_location方法。

//Portland, USA
CLLocationDegrees kMockedLatitude = 45.52306;
CLLocationDegrees kMockedLongitude = -122.67648;

-(CLLocation *)custom_location  
{  
   return [[CLLocation alloc] initWithLatitude:kMockedLatitude longitude:kMockedLongitude];
}

這甚至可以在iOS設備中使用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM