它会影响地图加载速度/性能吗? addAnnotation 与 addAnnotations
我知道这两个函数都可以处理我的地图视图上的多个点 - 我可以循环一组引脚并在每个引脚上执行 addAnnotation:pin
,或者我可以设置一个数组并使用 addAnnotations:arrayOfPins
方法...
但我想知道,因为我经常让程序添加一个新的注释,有时是几组,只使用 < code>addAnnotation:pin 在函数中,并循环一组(例如 30 或 40 个引脚),然后继续使用该函数在其他地方添加新引脚,而不是使用该函数,再加上一个要加载的函数引脚阵列?
基本上,循环遍历一堆addAnnotation调用一切比使用addAnnotation
单个注释要慢和/或更愚蠢,并且addAnnotations
用于注释集?
这不是一个大问题,我只是不知道使用数组函数是否更好?
I know that both of these two functions work with multiple points on my map view - I can either loop through a set of pins and do an addAnnotation:pin
on each one, or I can set up an array and use the addAnnotations:arrayOfPins
method...
But I'm wondering, since I will often have the program add a new annotation, and sometimes sets of a few, would it be okay to just use addAnnotation:pin
in a function, and loop through a set of, say, 30 or 40 pins, then keep using that function for adding new pins elsewhere, rather than have that function, plus a function to load in an array of pins?
Basically, is looping through a bunch of addAnnotation
calls for everything noticably slower and/or dumber than using addAnnotation
for single annotations, and addAnnotations
for sets of annotations?
It's not a huge issue, I just didn't know if using the array function was any better in any way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我自己的测试中,对于一小部分约 200 个引脚,看起来两者都不是更快。我将简单地使用一个函数一次添加一个注释,并通过另一个函数循环添加注释,因为这将使我的代码更简单一些。
但无论哪种方式都可能同样简单。
In my own testing, with a small set of some 200 pins, it doesn't look like either is faster. I'm going to simply use one function that adds one annotation at a time, and loop through adding annotations via another function, since that will make my code a little simpler.
But either way is probably just as easy.