我無法在iphone模擬器中獲取當前位置。我將自定義位置設置爲緯度和經度給埃及,但沒有得到當前位置。模擬器中的核心位置proplem
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//Make this controller the delegate for the map view.
self.MapView.delegate = self;
// Ensure that you can view your own location in the map view.
[self.MapView setShowsUserLocation:YES];
//Instantiate a location object.
locationManager = [[CLLocationManager alloc] init];
[locationManager startUpdatingLocation];
//Make this controller the delegate for the location manager.
[locationManager setDelegate:self];
//Set some parameters for the location object.
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
}
,這是委託:
#pragma mark - MKMapViewDelegate methods.
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKCoordinateRegion region;
region = MKCoordinateRegionMakeWithDistance(locationManager.location.coordinate,2000,2000);
[mv setRegion:region animated:YES];
}
請任何一個幫助我。
我的iPhone模擬器5.0版 哪裏可以找到這個窗口? – user1752619
在Xcode(不是模擬器)中,您可以通過單擊窗口左上角的兩部分下拉列表來編輯Scheme。或者,您可以按屏幕底部附近的位置服務圖標(跳過旁邊的箭頭,跳入,跳出) – Craig