我在做一個應用程序,我必須找到用戶的當前位置。我可以通過使用CLLocationmanager獲取用戶在iOS 5模擬器中的當前位置?在模擬器中的當前位置
6
A
回答
8
-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];
}
}
7
在Xcode中,您可以使用控制檯上方的小按鈕選擇要模擬的位置。
相關問題
- 1. iOS模擬器沒有當前位置
- 2. 當前位置在Android模擬器中不工作
- 3. 在Iphone模擬器中測試當前位置
- 4. 當前位置使用位置管理器在Android Studio模擬器
- 5. Iphone模擬器4.0找不到我的當前位置
- 6. iOS上的當前位置(5)模擬器不工作?
- 7. 在iPhone模擬器中設置位置
- 8. 模擬器位置
- 9. 如何在模擬器上獲取Windows Phone 7中的當前位置
- 10. Android模擬器中的GPS可以跟蹤我當前的位置嗎?
- 11. 在android中模擬位置
- 12. 模擬我目前的位置
- 13. 如何在Android模擬器中模擬GPS位置?
- 14. Android - 在IntelliJ模擬器問題中模擬位置
- 15. 如何在Android-x86模擬器(VirtualBox)中模擬gps位置?
- 16. 在模擬器上的Android位置
- 17. MKMapView不顯示當前位置,或者更確切地說,任何位置(在模擬器中)
- 18. 當前位置在java中
- 19. 無法模擬Android模擬器中的位置數據
- 20. 防止ios模擬器詢問「x想使用您當前的位置」
- 21. 我的Xcode模擬器的位置卡在自定義位置
- 22. Geo Fix未在Android模擬器中設置瀏覽器位置
- 23. 用位置預配置Android模擬器?
- 24. 在iPhone模擬器上模擬位置更新
- 25. 如何在Windows Phone 7模擬器上模擬位置?
- 26. Android模擬器在發送模擬位置時重新啓動
- 27. 模擬器上的地理位置?
- 28. Android模擬器:java.lang.OutOfMemoryError當操縱位圖
- 29. iOS SDK中當前位置的方位
- 30. iOS8 - 模擬器 - 如何獲取模擬的位置
希望你不介意,我格式化了你的答案了一下。但在第二次看到你的答案後:你確定這與OP的問題有關嗎? – 2012-04-28 16:59:39