不推荐使用的CLRegion方法-如何获取半径? [英] Deprecated CLRegion methods - how to get radius?

查看:112
本文介绍了不推荐使用的CLRegion方法-如何获取半径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 geocodeAddressString:completionHandler:方法,该方法返回一个CLPlacemarks数组。我必须获取纬度,经度,助记符名称和半径。虽然获得前三个很容易:

I'm using the geocodeAddressString:completionHandler: method, which returns an array of CLPlacemarks. I have to get latitude, longitude, mnemonical name and radius. While getting the first 3 is easy:

double lat = placemark.location.coordinate.latitude;
double lng = placemark.location.coordinate.longitude;
NSString *name = [NSString stringWithFormat:@"%@", ABCreateStringWithAddressDictionary(placemark.addressDictionary, NO)]

我现在不知道如何获取半径,因为已弃用 placemark.region.radius 。有什么想法现在改用什么吗?我在文档中找不到足够有趣的东西。

I don't know how to get the radius now, as placemark.region.radius is deprecated. Any ideas what to use now instead? I can't find anything interesting enough in documentation.

推荐答案

不赞成使用的注释用于 radius CLRegion 中的code>,它表示使用 CLCircularRegion 代替。

The deprecation note is for radius in CLRegion and it says to use CLCircularRegion instead.

请注意, CLCircularRegion CLRegion 的子类。

CLCircularRegion 具有与 CLRegion 相同的属性(包括半径 )。

Note that CLCircularRegion is a subclass of CLRegion.
CLCircularRegion has the same properties that CLRegion had (including radius).

这很重要,如果 you 是创建 CLRegion ,目的是使用其 radius 属性。

This matters if you are the one creating a CLRegion with the intention of using its radius property.



在这里,SDK本身(特别是 geocodeAddressString 方法)必须担心它并加以处理。


However, here, it is the SDK itself (specifically the geocodeAddressString method) which has to worry about it and handle it.

在iOS 7中,该方法确实通过为地标的 region 属性返回 CLCircularRegion 来处理它。

In iOS 7, that method indeed handles it by returning a CLCircularRegion for the placemark's region property.

基本上,由于属性名称相同,因此您无需在此处做任何更改。

Essentially, you don't have to do or change anything here since the property names are identical.

此代码将起作用从iOS 4到iOS 7:

This code will work from iOS 4 to iOS 7:

NSLog(@"radius=%f", placemark.region.radius);

这篇关于不推荐使用的CLRegion方法-如何获取半径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆