UICollectionView 和图像 [英] UICollectionView and images
问题描述
我有一个 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屋!