我在做一个应用程序,我必须找到用户的当前位置。我可以通过使用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. iOS 6 MKMapview - 当前位置在模拟器中显示错误
- 3. 在Iphone模拟器中测试当前位置
- 4. futuretap/FTLocationSimulator在iPhone模拟器中测试当前位置
- 5. 当前位置在Android模拟器中不工作
- 6. 当前位置使用位置管理器在Android Studio模拟器
- 7. Iphone模拟器4.0找不到我的当前位置
- 8. iOS上的当前位置(5)模拟器不工作?
- 9. 使用Trigger.io和Android模拟器获取我的当前位置
- 10. 模拟器位置
- 11. iPhone模拟器4.3与xcode 4不显示当前位置
- 12. 如何获取用户在iphone SDK中的模拟器当前位置?
- 13. 如何在模拟器上获取Windows Phone 7中的当前位置
- 14. Android模拟器中的GPS可以跟踪我当前的位置吗?
- 15. 在android中模拟位置
- 16. 模拟我目前的位置
- 17. 模拟位置在Android Studio模拟器中不起作用
- 18. Android - 在IntelliJ模拟器问题中模拟位置
- 19. 如何在Android模拟器中模拟GPS位置?
- 20. 如何在Android-x86模拟器(VirtualBox)中模拟gps位置?
- 21. 模拟器中的核心位置proplem
- 22. 在模拟器上的Android位置
- 23. MKMapView不显示当前位置,或者更确切地说,任何位置(在模拟器中)
- 24. 当前位置在java中
- 25. 无法模拟iOS模拟器中的移动位置
- 26. 无法模拟Android模拟器中的位置数据
- 27. 我的Xcode模拟器的位置卡在自定义位置
- 28. 防止ios模拟器询问“x想使用您当前的位置”
- 29. 钛地理位置在Android模拟器
- 30. Geo Fix未在Android模拟器中设置浏览器位置
希望你不介意,我格式化了你的答案了一下。但在第二次看到你的答案后:你确定这与OP的问题有关吗? – 2012-04-28 16:59:39