How to make an increase in UICollectionView

I have uicollectionview uicollectionview codes with CustomCollectionViewLayout , and inside there is a lot of small cells , but the user cannot see them without zoom . All cells are also available.

I want to add my collection view inside the zoom function!

My clear codes are below.

 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 } strongSelf.items = responseData customCollectionViewLayout.dataSourceDidUpdate = true NSOperationQueue.mainQueue().addOperationWithBlock({ () -> Void in strongSelf.collectionView!.reloadData() }) } } } extension CustomCollectionViewController { override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { return items.count } override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return items[section].services.count + 1 } override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! CustomCollectionViewCell cell.label.text = items[indexPath.section].base return cell } override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath cellForItemAtIndexPath: NSIndexPath) { print(items[cellForItemAtIndexPath.section].base) } } 

Also my uicollectionview layout uicollectionview below you can see that I have selected maxZoom 4 , but doesnt have any effect!

enter image description here

Thanks!

+6
source share
2 answers

You are not zooming in on the collection, as if you had increased the ease of scrolling. Instead, you should add a pinch gesture (or some other zoom mechanism) and use it to change the layout so that your grid displays a different number of elements in the visible part of the collection. This basically changes the number of columns and therefore the size of the element (cell size). When you update the layout, the collection can be animated between different sizes, although it is unlikely that you would zoom in smoothly, you want it to go straight from N columns to N-1 columns in step.

+1
source

I think what you are asking for is similar to what was done in WWDC1012 video titled Advanced Collections and Creating Custom Layouts (demonstration starts at 20:20) https://www.youtube.com/watch ? v = 8vB2TMS2uhE

Basically you have to add pinchGesture to the UICollectionView, and then pass the pinch properties (scale, center) to the UICollectionViewLayout (which is a subclass of UICollectionViewFlowLayout), then your layout will perform the transformations necessary to increase the required cell.

+1
source

All Articles