简体   繁体   English

在没有CATiledLayer的iOS上显示和缩放大图像

[英]Present and zoom large images on iOS without CATiledLayer

I'd like to present and allow the user to zoom large images on the iPhone and iPad in much the same way that the Photos app works. 我想展示并允许用户以与“照片”应用程序相同的方式缩放iPhone和iPad上的大图像。

I realize CATiledLayer is the goto class for this, but the aesthetic it uses won't work for my application. 我意识到CATiledLayer是该类的goto类,但是它所使用的美感不适用于我的应用程序。 It renders tiles one after another, while the Photos app renders the whole screen at once (and shows a pixellated version during and after a zoom until the app can catch up). 它一个接一个地渲染图块,而“照片”应用程序一次渲染整个屏幕(并在缩放过程中和缩放之后显示像素化版本,直到应用程序赶上来)。

I could certainly implement a view which renders the image in the background after each zoom. 我当然可以实现一个视图,该视图在每次缩放后在背景中渲染图像。 However, once the source image gets to large, this will crash the app. 但是,一旦源图像变大,这将使应用程序崩溃。 So tiling is appealing, I would just prefer to not update the screen until all tiles are ready (and show a lower-res image in the meantime). 因此,平铺很有吸引力,我只希望在所有平铺都准备好之前不更新屏幕(同时显示较低分辨率的图像)。

Has anyone tried to implement something like this? 有没有人试图实现这样的事情? Any ideas? 有任何想法吗?

Apple's PhotoScroller and ScrollViewSuite samples show how to do this and more. 苹果公司的PhotoScroller和ScrollViewSuite示例演示了如何执行此操作以及更多操作。

There's also a 2010 WWDC video titled "Designing Apps with Scroll Views" that explains PhotoScroller. 还有一个2010年的WWDC视频,标题为“使用滚动视图设计应用程序”,其中介绍了PhotoScroller。

I guess you can have two views: one ImageView with a low res image, and on top a custom view with a CaTiledLayer, with transparent background and hidden at the beginning. 我猜您可以有两个视图:一个具有低分辨率图像的ImageView,以及一个带有CaTiledLayer的自定义视图,该视图具有透明背景并且在开始时是隐藏的。

So, when zooming (you'll need to apply zoom to both views) and you need extra resolution, just show the catiledlayered view, so it will load tiles while showing the lowres (and pixelated) on not loaded tiles. 因此,在缩放时(您需要将缩放应用于两个视图)并且需要额外的分辨率,只需显示catiledlayered视图,这样它将加载图块,同时在未加载的图块上显示低分辨率(和像素化)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM