gpt4 book ai didi

ios - 如何在ios中将当前位置用户头像居中

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:00:41 25 4
gpt4 key购买 nike

我需要在 MKView 上将当前位置的用户图片居中。但目前它不在中心,如下面的屏幕截图所示。

enter image description here -

 (void)locationManager:(CLLocationManager *)manager didFailWithError:   (NSError *)error
{
NSLog(@"didFailWithError: %@", error);
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);

CLLocation *currentLocation = newLocation;

if (currentLocation != nil)
{
NSLog(@"%@",[NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude]);

NSLog(@"%@",[NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude]);

// [mkMapView setCenterCoordinate:mkMapView.userLocation.location.coordinate animated:YES];
}
}

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 150, 150);

[mkMapView setRegion:[mkMapView regionThatFits:region] animated:YES];
}

最佳答案

- (void)mapView:(MKMapView *)aMapView didUpdateUserLocation:(MKUserLocation *)aLocation {

MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta = 0.005;
span.longitudeDelta = 0.005;
CLLocationCoordinate2D location;
location.latitude = aLocation .coordinate.latitude;
location.longitude = aLocation .coordinate.longitude;
region.span = span;
region.center = location;
[aMapView setRegion:region animated:YES];

关于ios - 如何在ios中将当前位置用户头像居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37065217/

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