我很迷惑.我有一个UICollectionView.我有自己的UICollectionViewLayout子类(哇,我没有使用Flow的东西).UICollectionViewinstance是的子类UIScrollView.它添加了多个子视图.但是像Properly缩放包含许多子视图的UIScrollView这样的问题似乎说可滚动视图应该只有一个子视图来"滚动整个视图".似乎与我的婚姻不一致.我的意思是为什么Apple给我一个用于制作多个子视图的框架,然后将它们全部放在滚动视图中,这不应该运行良好?
所以我很好奇我应该如何使我的整体UICollectionView(它在一个UICollectionViewController子类中)可缩放.我是否需要实现各种委托方法并使布局对象无效/操作,根据我在布局中保留的某些属性派生布局?还是有其他机制?
除此之外,为什么它不能只是操纵zoomScale财产并为我自动执行?或者我在这里错过了一些微妙的东西?
我有一个iPad应用程序,我正在使用UICollectionView,每个UICollectionViewCell只包含一个UIImage.目前我每页显示每9个UIImages(3行*3列),我有几页.
我想使用Pinch Gesture缩放整个UICollectionView来增加/减少每页显示的行数/列数,最好是在Pinch手势期间获得漂亮的缩放动画!
目前,我在我的UICollectionView上添加了一个Pinch Gesture.我抓住Pinch Gesture事件使用比例因子计算行数/列数,如果它已经改变,那么我使用以下方法更新完整的UICollectionView:
[_theCollectionView performBatchUpdates:^{
[_theCollectionView deleteSections:[NSIndexSet indexSetWithIndex:0]];
[_theCollectionView insertSections:[NSIndexSet indexSetWithIndex:0]];
} completion:nil];
Run Code Online (Sandbox Code Playgroud)
它有效,但在过渡期间我没有平滑的动画.
任何的想法?UICollectionView继承自UIScrollView,是否有可能重用UIScrollView Pinch手势功能来实现我的目标?
我有工作uicollectionview代码CustomCollectionViewLayout,内部有,a lot of small cells但用户无法看到它们zoom.所有细胞也可选择.
我想在缩放功能中添加我的集合视图!
我的明确代码如下.
class CustomCollectionViewController: UICollectionViewController {
var items = [Item]()
override func viewDidLoad() {
super.viewDidLoad()
customCollectionViewLayout.delegate = self
getDataFromServer()
}
func getDataFromServer() {
HttpManager.getRequest(url, parameter: .None) { [weak self] (responseData, errorMessage) -> () in
guard let strongSelf = self else { return }
guard let responseData = responseData else {
print("Get request error \(errorMessage)")
return
}
guard let customCollectionViewLayout = strongSelf.collectionView?.collectionViewLayout as? CustomCollectionViewLayout else { return } …Run Code Online (Sandbox Code Playgroud)