UICollectionView 和图像 [英] UICollectionView and images

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

问题描述

我有一个 UICollectionView,效果很好,但我有疑问.在我看来,我有一个 UICollectionViewCell,里面有一个 UIImage.该单元格链接到一个空白视图控制器,在其中我有一个 UIScrollView(用于管理缩放)和一个 UIImage(全尺寸图像).

我想知道是否有一些委托或其他东西可以自动处理图像打开过程(使用缩放等).

现在我正在用UIScrollViewDelegate委托和方法viewForZoomingInScrollView:处理缩放效果……但结果很差,绝对不流畅!

解决方案

没有内置的视图来做你想做的事,没有.您正在使用 UIScrollView 中的 UIImageView 做正确的事情.如果它不是很流畅,那么可能是因为您的图像很大.解决这个问题的方法是为不同的缩放级别加载不同的图像.因此,当您放大时,请收听名为 scrollViewDidZoom:UIScrollViewDelegate 方法,并在放大时将图像更改为更好的分辨率.或者,查看 CATiledLayer.

请注意,这与您的 UICollectionView 无关.

I have a UICollectionView, and it works great, but I have a doubt. In my view I have a UICollectionViewCell and inside that I have a UIImage. The cell is linked to a blank view controller, and inside that I have a UIScrollView (for managing the zoom) and a UIImage (the full-size image).

I wondered if there was some delegate or something that could handle the image opening process automatically (with zoom, etc.).

Now I'm handling the zoom effect with UIScrollViewDelegate delegate and method viewForZoomingInScrollView:... but the result is very poor, definitely not fluid!

解决方案

There's no built in view for doing what you want, no. You're doing the right thing with a UIImageView inside UIScrollView. If it's not very fluid, then it's likely because your image is huge. The way to get around that is to load different images for different zoom levels. So as you zoom in, listen to the UIScrollViewDelegate method called scrollViewDidZoom: and change the image to better resolution as you zoom in. Or, take a look at CATiledLayer.

Note that this has nothing to do with your UICollectionView.

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

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