显示在图形页面用户位置

问题描述 投票:9回答:4

我与显示一些注解一个MapView写一个应用程序。

现在我想显示的MapView用户的当前位置。我得到使用此代码当前位置:

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)location

我得到的当前位置的细节在日志

2013-10-14 12:03:34.291 AppName[13200:a0b] (
"<+7.35000000,+47.32000000> +/- 5.00m (speed -1.00 mps / course -1.00) @ 10/14/13, 12:03:34 PM Central European Summer Time")

现在我不明白的位置进入的MapView,因为这蓝色脉冲点。

请给一些提示。

ios ios7 mkmapview cllocation
4个回答
28
投票

您可以启用通过这个用户位置:

mapView.showsUserLocation = YES;

如果你想在这个位置中心:

[mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES];

如果您正在使用:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{

if ([annotation isKindOfClass:[MKUserLocation class]]) {
    return nil;
}

// etc...


}

3
投票

在iOS10我无法获取用户位置的蓝色圆点显示,直到将密钥NSLocationWhenInUseUsageDescription我的Info.plist,用怎样的位置信息会在应用程序中使用的字符串描述。


0
投票

在Xcode 9,你可以用故事板文件做

enter image description here


0
投票

我遇到同样的,因为我删除了我喜欢的类型校验码为AnnotationViews因为我不需要再这样了。所以我做了@ incmiko的回答迅捷的版本。

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {

    guard !annotation.isKind(of: MKUserLocation.self) else { return nil }

    //create annotation view

    return MKAnnotationView()
}
© www.soinside.com 2019 - 2024. All rights reserved.