iphone - MKAnnotation协议(protocol)的 "coordinate"属性

标签 iphone objective-c cocoa-touch

我的问题是关于“坐标”属性的“只读”属性。在协议(protocol)中还列出了一个“setCoordinate”即时方法。它在文档中说它是为了支持“拖动”。

我的问题是:

1

如果可以设置坐标,那为什么要给它分配一个“只读”属性?

2

我正在考虑使用单个临时 MKAnnotation 对象来填充数组。方案是分配不同的坐标值,重复添加到数组中。但如果坐标属性为“只读”,该方案将不起作用。或者我是否可以为此目的使用“setCoordinate”?

我只是希望避免必须创建多个 MKAnnotation 对象来填充数组(因为数组可能不仅仅是几个点)。

希望这方面的知识渊博的人可以帮助...

http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKAnnotation_Protocol/Reference/Reference.html

最佳答案

setCoordinate: 方法是可选的。如果您的注释支持拖动,您可以实现它,但不是必须的。另一方面,只读属性是强制性的。

I am thinking of using a single temporary MKAnnotation object to populate an array. The scheme is to assign different coordinate values and add it to the array repeatedly. But the scheme would not work if the coordinate property is "readonly". Or can I use the "setCoordinate" for this purpose anyway ?

这个方案在任何情况下都行不通。如果您将注释添加到您的数组,然后修改坐标并再次添加它,您的数组中将有两次完全相同的注释,具有相同的坐标。如果您想要一组具有不同坐标的注释,则需要为每个坐标创建一个不同的注释对象。

关于iphone - MKAnnotation协议(protocol)的 "coordinate"属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7642311/

相关文章:

iphone - 如何通过另一个 CGMutalbePathRef 剪辑或减去 CGMutablePathRf?

iPhone/iPad 浏览器模拟器?

ios - nil 不是用于搜索实体名称 'GroupMessageInfo' 的合法 NSPersistentStoreCoordinator

ios - 自定义 UIViewController 中的内存管理

ios - objective-c :检查int是否存在,包括零

iphone - 每个线程都需要自己的自动释放池吗?

iPhone Gameloop 从单独的线程渲染更新

iOS:多行 UILabel 与水平 UIStackView 中的另一个 UILabel 的大小错误

iOS - SSL 握手 - 客户端证书 - NSURLSession - NSURLErrorDomain 代码=-1200 - 错误链

objective-c - 如何让 Emacs magic-mode-alist 匹配文件中间的字符串