Scroll two collection view at one time, bug IOS 15

Hi, we are using collection views in table view (like Netflix layout). With IOS 15 we have issue with scrolling collection. When we scroll one of the collection, the second one (under first and should be partially hidden under screen) scrolls too. This occurs when we scroll for the first time, after that everything is ok. Do you have any ideas what changed in iOS 15 that such an issue occurs?

Does it occur when you scroll collection 1 and when you scroll collection 2 at first time ? What are the constrains for each collectionView ?

I created a simple VC with 2 collectionViews, no constraint defined:

Code of the VC is very basic:

import UIKit

class TestViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
    
    @IBOutlet weak var collection1: UICollectionView! // delegate and dataSOurce defined in IB
    
    @IBOutlet weak var collection2: UICollectionView!
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        20
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let id = collectionView.tag == 1 ? "Standard1" : "Standard2"
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: id, for: indexPath)

        for v in cell.contentView.subviews {
            v.removeFromSuperview()
        }

        cell.backgroundColor = collectionView.tag == 1 ? .red : .systemYellow
        
        let label = UITextView(frame: CGRect(x: 5, y: 4, width: 30, height: 20))
        label.text = String(indexPath .row)
        cell.contentView.addSubview(label)
        
        return cell
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        collection1.tag = 1
        collection2.tag = 2

    }
    
}

I run in iOS 15.0 simulator with Xcode 13RC and at start I can scroll first collection without moving second.

So, you have probably defined something else in your project that causes this behavior.

Re reading your post :

under first and should be partially hidden under screen

What do you mean by "under screen" ? Do you mean below screen limit ? under first Collection ?

I tested both cases, without replicating the problem.

To fully answer the question, I added a tableView with 2 rows, each containing a CollectionView.

It still works OK, even at first scroll, as the screen capture illustrates:

Code for creating the collections:

import UIKit

class TestViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UITableViewDelegate, UITableViewDataSource {
    
    @IBOutlet weak var collection1: UICollectionView!
    
    @IBOutlet weak var collection2: UICollectionView!
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        2
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCell(withIdentifier: "CellItemForCollection", for: indexPath)
        
        let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
        layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
        layout.itemSize = CGSize(width: 50, height: 50)
        
        let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 260, height: 120), collectionViewLayout: layout)

        collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "MyCell")
        collectionView.backgroundColor = UIColor.clear

        collectionView.dataSource = self
        collectionView.delegate = self
        
        collectionView.tag = 10 + indexPath.row // 10 or 11
        cell.contentView.addSubview(collectionView)

        return cell
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        20
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        var id = ""
        switch collectionView.tag {
        case 1 : id = "Standard1"
        case 2 : id = "Standard2"
        case 10, 11: id = "MyCell"
        default: break
        }
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: id, for: indexPath)

        for v in cell.contentView.subviews {
            v.removeFromSuperview()
        }

        switch collectionView.tag {
        case 1 : cell.backgroundColor = .red
        case 2 : cell.backgroundColor = .systemYellow
        case 10: cell.backgroundColor = .systemBlue
        case 11: cell.backgroundColor = .systemGreen
        default: break
        }
        
        let label = UITextView(frame: CGRect(x: 5, y: 4, width: 30, height: 20))
        label.text = String(indexPath .row)
        cell.contentView.addSubview(label)
        
        return cell
    }
    

    override func viewDidLoad() {
        super.viewDidLoad()
        collection1.tag = 1    // The top collections (out of TableView)
        collection2.tag = 2
    }
    
}

Did you solve the issue ? If not, could you explain what is different from the set up I tested ?

Scroll two collection view at one time, bug IOS 15
 
 
Q