2011-03-01 101 views
0

我有一个MKMapView,它的委托设置为我的控制器(m)类。下面MKMapView不显示当前位置,或者更确切地说,任何位置(在模拟器中)

代码:

-(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; 

} 

然而,所有我看到的是世界地图没有标注的蓝色圆点一个?

回答

1

该模拟器不“真的”支持。如果您绕过足够的检查,它将显示Apple的总部。任何GPS测试你需要一个真实的设备。编辑:我相信你可以放一个别针,它会显示,但至于从CLLocationManager(通过CLLocationManagerDelegate)回调,它不是在模拟器中开心;至少最近的那些。我不能代表任何东西之前3.0说话......

1
self.mapview.mapType = MKMapTypeStandard; 
    self.mapview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 
    self.mapview.showsUserLocation = YES; 

这是你所需要的,如果你有一个指针到地图称为MapView的,但作为Merky说,你需要一个真正的设备。你可以做的是,当模拟器运行时,进入“调试 - >位置 - >自己的位置”并输入你想要的坐标的坐标。