像UiTableView一样加载UIScrollView [英] Loading a UIScrollView like a UiTableView

查看:47
本文介绍了像UiTableView一样加载UIScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种类似于加载UITableView的方式加载UIScrollView的方法-换句话说,仅加载可见的单元格"?

Is there a way to load a UIScrollView in a similar way to how a UITableView is loaded - in other words, only load the visible 'cells'?

在我的示例中,我有一个大的滚动视图,可以向任何方向滚动.在其中是单元格",我使用代码将其添加到滚动视图中.单元格由从json提要(每个单元格一个提要)收集的数据组成.我只想加载可见单元的提要,然后缓存已经加载的提要,因此不需要重新加载它们.

For my example I have a large scroll view which can be scrolled in any direction. Inside that are 'cells' which I add to the scroll view using code. The cells consist of data gathered from json feeds (one feed per cell). I would like to only load the feeds for the visible cells, and then cache the ones already loaded, so they don't need to be reloaded.

有一个好的方法吗?还是我应该采取另一个方向来获得这个结果?

Is there a good method of doing this? Or is there another direction I should be taking to get this result?

有两个答案提出了一种切片方法,但是我不确定切片是否是正确的方法,因为需要在部分可见时加载整个单元格.谷歌暗示的另一种方法是将UITableView放在UIScrollView中,但是我还没有尝试过.

A couple of answers have suggested a tiling approach, but I'm not sure that tiling is quite the right approach, since the whole cell needs to be loaded when part of it is visible. Another approach which google hints at is putting a UITableView within a UIScrollView, but I've yet to try this.

         ——————————----------------------
         |        |                     |  < a 'cell' row in the scrollview
         | - - - -| - - - - - - - - - - |
screen > |        |                     |
         |        |                     |
         ——————————                     |
         |                              |  < whole of scrollable area
         |                              |
         |                              |
         |                              |
         --------------------------------

推荐答案

您可以使用CATiledLayer.

You can use CATiledLayer.

https://stackoverflow.com/questions/tagged/catiledlayer

https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CATiledLayer_class/Introduction/Introduction.html

这篇关于像UiTableView一样加载UIScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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