我在做一个应用程序,我必须找到用户的当前位置。我可以通过使用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