我的问题是关于“坐标”属性的“只读”属性。在协议(protocol)中还列出了一个“setCoordinate”即时方法。它在文档中说它是为了支持“拖动”。
我的问题是:
1
如果可以设置坐标,那为什么要给它分配一个“只读”属性?
2
我正在考虑使用单个临时 MKAnnotation 对象来填充数组。方案是分配不同的坐标值,重复添加到数组中。但如果坐标属性为“只读”,该方案将不起作用。或者我是否可以为此目的使用“setCoordinate”?
我只是希望避免必须创建多个 MKAnnotation 对象来填充数组(因为数组可能不仅仅是几个点)。
希望这方面的知识渊博的人可以帮助...
最佳答案
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/