Objective c MKMapView不显示当前位置,或者更确切地说,不显示任何位置(在模拟器中)
我有一个MKMapView,它的委托设置为我的控制器(m)类 代码如下:Objective c MKMapView不显示当前位置,或者更确切地说,不显示任何位置(在模拟器中),objective-c,mapkit,core-location,Objective C,Mapkit,Core Location,我有一个MKMapView,它的委托设置为我的控制器(m)类 代码如下: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Create location manager object locationManager = [[CLLocationManager alloc] init]; // Make
-(BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Create location manager object
locationManager = [[CLLocationManager alloc] init];
// Make this instance of WhereamiAppDelegate the delegate
// it will send its messages to our WhereamiApplDelegate
[locationManager setDelegate:self];
// We want all results from the location manager
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[mapView setShowsUserLocation:YES];
[window makeKeyAndVisible];
return YES;
}
然而,我看到的只是一张没有蓝色注释点的世界地图?模拟器“真的”不支持这一点。如果你绕过足够多的检查,它将显示苹果的总部。任何GPS测试都需要一个真正的设备
编辑:我相信你可以删除一个pin码,它会显示出来,但是对于从CLLocationManager(通过CLLocationManagerDelegate)的回调,它不会在模拟器中发生;至少是最近的。在3.0之前我什么都不能说
self.mapview.mapType = MKMapTypeStandard;
self.mapview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.mapview.showsUserLocation = YES;
如果你有一个指向地图的名为mapView的指针,这就是你所需要的,但正如Merky所说,你需要一个真正的设备。但是,您可以做的是,当模拟器运行时,转到“调试->位置->自己的位置”,并输入所需坐标的坐标