gpt4 book ai didi

iphone - 模拟器中的核心位置问题

转载 作者:行者123 更新时间:2023-11-28 20:28:54 25 4
gpt4 key购买 nike

我无法在 iphone 模拟器中获取我的当前位置。我将自定义位置设置为埃及的经纬度,但无法获取当前位置。

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

这是委托(delegate):

#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];
}

请任何人帮助我。

最佳答案

到底是什么问题?没有获得您应该拥有的 userLocation 或没有将 map 区域移动到正确的位置?

如果是第一个,多半是工具问题,不是代码问题:

如果您的位置在项目中的 gpx 文件中,您应该能够通过编辑 Scheme/Options/Allow Location Simulation/并选择默认位置来开始它

Scheme Edition for starting at a specific place

您的项目中应该有一个 DemoStart.gpx 文件,如下所示:

<?xml version="1.0"?>
<gpx version="1.1" creator="Xcode">
<wpt lat="20.88072" lon="10.67429">
<name>Demo Starting Location</name>
</wpt>
</gpx>

(抱歉,我懒得去找埃及的确切坐标)。

关于iphone - 模拟器中的核心位置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13027511/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com