如何在 iPhone 上创建时间线
我试图在我的 iPhone 应用程序中创建一个无限的时间线来滚动时间。我想我将使用 UIScrollView 来做到这一点,但我不确定如何做到这一点。
我是否应该从头开始创建一个可重用的视图队列,其中包含日/月/年的视图,并在它们离开屏幕时重用它们? (我想到的是表格视图中的可重用单元格)。
也许有更好的方法来做到这一点? 感谢您的帮助 !
I am trying to create an inifite timeline in my iPhone app to scroll through time. I think I am going to use a UIScrollView to do that but I am not sure how to do that.
Am I supposed to create a reusable queue of views from scratch with views containing the days/months/years and reuse them when they go out of the screen ? (I have in mind the reusable cells from the tableviews).
Maybe there is a better way to do that ?
Thanks for your help !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,UIScrollView从3.0开始就没有宽度限制了。然而,您不能使用它来显示大量数据,因为绘制它会花费太多时间,并且您的应用程序将运行缓慢。
您可以使用宽度 = 320.0 * 3 的 UIView 代替。处理
并
在此处应用 Shift 可以根据从触摸集中找到的 delta X 进行计算。仿射平移可以模拟平滑的运动。当用户释放手指(touchesEnded)时,使用移动的内容重绘您的视图(setNeedsDisplay)并将其取回:
self.transform = CGAffineTransformIdentity;
不要在touchesMoved时执行setNeedsDisplay,因为如果您这样做,它可能会影响性能正在绘制图表或计算某些东西。
对于 2D 地图,您必须同时考虑 X 和 Y,并拥有 320*3 X 480*3 视图:)
这是一项有趣的任务。享受。
As far as I know, UIScrollView doesn't have width limitation since 3.0. Nevertheless, you cannot use it to display large amount of data because it would take too much time to draw it and your application will work slow.
You can use UIView of width = 320.0 * 3 instead. Handle
And apply
Shift here can be calculated depending on delta X found from touches set. Affine translation allows to emulate smooth movement. When user releases their finger (touchesEnded), redraw your view (setNeedsDisplay) with shifted content and get it back:
self.transform = CGAffineTransformIdentity;
Don't do setNeedsDisplay while touchesMoved because it can affect performance if you are drawing graphs or calculating something.
For 2D map you would have to think about both X and Y and have 320*3 X 480*3 view :)
It's interesting task. Enjoy.
好吧,
UIScrollView
是有限的,因此您将在某个时刻到达终点。您当然可以前后移动物品,以确保您永远不会达到该限制。您当然希望对
UITableView
进行一些缓存/分页,以确保只在内存中保留所需的最少视图。如果您准备好,请提出更具体的问题:-)
Well, the
UIScrollView
is finite, so you will hit the end at one point. You can of course move items around (back) to make sure you will never hit that limit.You certainly want to do some caching/paging ala
UITableView
to make sure you only keep the minimal needed views in memory.Ask a more specific question if you are ready for that :-)