我从这个方法获取用户位置
/*Region and Zoom*/
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.2;
span.longitudeDelta=0.2;
CLLocation *location1 = [locationManager location];
CLLocationCoordinate2D location = [location1 coordinate];
location.latitude = location.latitude;
location.longitude = location.longitude;
region.span=span;
region.center = location;
/*Geocoder Stuff*/
MKReverseGeocoder *geoCoder=[[MKReverseGeocoder alloc] initWithCoordinate:location];
geoCoder.delegate = self;
[geoCoder start];
mapView.showsUserLocation = TRUE;
[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
Run Code Online (Sandbox Code Playgroud)
这很好用,但是当我尝试在模拟器中运行此代码时,它会在此处崩溃,[mapView setRegion:region animated:TRUE];告知它不会获得纬度和经度值.那么如何让这个代码在模拟器中完美运行呢.
我必须让这个代码在模拟器中运行,这可能吗?
Sat*_*yam 14
在iOS5模拟器上,默认情况下,它将在美国显示一些位置.如果要更改该位置,请在iOS模拟器菜单中,转到"调试" - >"位置" - >"自定义位置".在那里,您可以设置纬度和经度,并相应地测试应用程序.这适用于mapkit以及CLLocationManager.
| 归档时间: |
|
| 查看次数: |
10776 次 |
| 最近记录: |