如何为 UICollectionView 启用缩放 [英] How to enable zoom for UICollectionView
问题描述
我很困惑.我有一个 UICollectionView
.我有自己的 UICollectionViewLayout
子类(iow,我没有使用 Flow 的东西).UICollectionView
实例是 UIScrollView
的子类.它添加了多个子视图.但是像 正确缩放包含许多子视图的 UIScrollView 这样的问题似乎说可滚动视图应该只有一个子视图来滚动整个视图".对我来说,这似乎是一种不一致的婚姻.我的意思是为什么 Apple 给我一个框架来制作多个子视图,然后将它们全部粘贴在滚动视图中,这不应该很好用?
I am confused. I have a UICollectionView
. I have my own UICollectionViewLayout
subclass (iow, I am not using the Flow thing). UICollectionView
instance is a subclass of UIScrollView
. It adds multiple subviews. But questions like Properly zooming a UIScrollView that contains many subviews seem to say that scrollable views should just have one subview to "scroll the whole view". Seems kind of an inconsistent marriage to me. I mean why does Apple give me a framework for making a multiple child view, and then stick them all in scroll view, which isn't supposed to work well?
所以我很好奇我应该如何让我的整个 UICollectionView
(它在 UICollectionViewController
子类中)可缩放.我是否需要实现各种委托方法并使布局对象无效/操作,根据我保留在布局中的某些属性派生布局?还是有其他机制?
So I'm curious how I should go about making my whole UICollectionView
(it's in a UICollectionViewController
subclass) zoomable. Do I need to implement various delegate methods and invalidate/manipulate the layout object, deriving the layouts based on some property I keep in my layout? Or is there some other mechanism?
除此之外,为什么它不能只操纵 zoomScale
属性并自动为我完成它?还是我在这里遗漏了一些微妙之处?
Aside, why can't it just manipulate the zoomScale
property and do it automagically for me? Or am I missing some subtlety here?
推荐答案
我不确定你的问题是否正确,但我想你可能想检查这些链接:-
1.缩放整个 UICollectionView - 它还有一个链接到 UICollectionView 的示例代码.您可能有兴趣检查它.
2.向 UICollectionView 添加捏合缩放.
3.使 UICollectionView 可缩放?
I am not sure whether I got your question in correct way or not, but I think you might want to check these links:-
1. zoom entire UICollectionView - It also has a link to Sample code for UICollectionView. You might be interested in checking it.
2. Adding pinch zoom to a UICollectionView.
3. Make UICollectionView zoomable?
希望这会对你有所帮助.
Hope this will help you.
这篇关于如何为 UICollectionView 启用缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!