8

I've seen the WDC2010 Session 104 for using scrollviews and CATiledLayers, which is all pretty cool. But I'm not sure about the generation of the tile images. The example had the frog tile pictures already created. But if I have a photo app where I am taking my own photos, I will need to create the tiles myself and I'm not sure of the best approach to take.

Easiest method would be as soon as I take a photo and store it, I do some image manipulation and create all the possible tiles I need. But that means for every photo, I'm storing a lot more files and using more file space.

Just before I need the photo, I create the tiles into a temp directory. When I've finished the viewing part I can delete that temp directory. At least I'm only using the extra file space when viewing the photos. But I'd be concerned about loading the image to create tiles as to whether I introduce a delay which is noticeable to the user.

4

1 回答 1

1

您不需要保存平铺图像。基本上,您将根据显示的矩形创建 UIImage/CGImage。

我在这里做过类似的事情,效果很好,好处是它对内存非常有效。我根据正在显示的矩形动态生成 CGImage(大图像中的小图块),TiledLayer 在转储矩形时将其从内存中删除。我从不将 CGImage 保存到文件中。

这种方法的缺点是它在渲染中引入了延迟……不适合在 iphone 3g 上玩游戏。

于 2010-10-24T08:29:02.900 回答