2011-03-01 98 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說,你需要一個真正的設備。你可以做的是,當模擬器運行時,進入「調試 - >位置 - >自己的位置」並輸入你想要的座標的座標。