title: How to change the content offset of a UICollectionView simultaneously?
body: <p>I have a horizontal scrollable collectionView with two cells that take up the screen. Inside those cells is an embedded collection view that scrolls vertically. Is there a way for me to scroll the vertical CV inside the first cell, while using its ContentOffset to scroll the vertical CV in the second cell?</p>
  
  <p>Here's how I'm trying to accomplish it:</p>
  
  <pre><code>let scrollView = notification.userInfo!["scrollView"] as! UICollectionView
  if scrollView.contentOffset.y &lt;= 250.0 {
     childViewControllerForPosts.collectionViewForGroups?.collectionView.setContentOffset(CGPointMake(0, scrollView.contentOffset.y), animated: false)
  
          self.topVerticalConstraint?.constant = -scrollView.contentOffset.y
  
      }
      else {
  
          if self.topVerticalConstraint?.constant &gt; -250 {
              // Make sure it stays at -250
              self.topVerticalConstraint?.constant = -250
          }
  
      }
  </code></pre>
  
  <p>The <code>FeedCell</code> would be the main collection view (which horizontally scrolls) that contains the vertical scrolling collection view. I'm trying to access the second one to change the vertical contentOffset when I scroll the one in first one.</p>
  
  <p>Here's how I'm trying to save the variable that should contain the second main collection view:</p>
  
  <p><code>collectionViewForGroups = collectionView(collectionView!, cellForItemAtIndexPath: NSIndexPath(forItem: 1, inSection: 0)) as? FeedCell</code></p>
  
  <p>EDIT:
  Note that when I scroll horizontally, the vertical scroll view didn't change. But I want it to change with the one I just scrolled in the gif. If I were to scroll the 2nd vertical collection view, the UIView above will reappear because the topLayConstraint changes due to the vertical contentOffset change.</p>
  
  <p><a href="https://i.stack.imgur.com/U6YNq.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U6YNq.gif" alt="enter image description here"></a></p>