title: How can I toggle between 2 different UICollectionViewFlowLayout instances?
body: <p>Been working on this for a few days now. I'm trying to allow customers of an app to switch between 2 display types when shopping. </p>
  
  <p>Right now I'm using 2 <code>UICollectionView</code>'s with their own custom <code>UICollectionViewCell</code> and the switching between the two works fine but I'm finding that working with 2 different <code>UICollectionView</code>'s is becoming a pain. Certain things I've implemented for my main <code>UICollectionView</code> don't work properly in the alternative <code>UICollectionView</code>.</p>
  
  <p><strong>This is how the display is changed. I use a <code>UISegmentedControl</code> with a custom method:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/heerr.png" alt="enter image description here"></p>
  
  <pre><code>- (void)displayTypeSegmentSelected
  {
      _selectedDisplayTypeIndex = [_displayTypeControl selectedSegmentIndex];
  
  
      if (_selectedDisplayTypeIndex == 0) {
          NSLog(@"Single file item view selected");
          _fromCollectionView = _collectionView;
          _toCollectionView = _collectionView2;
  
  
      } else if (_selectedDisplayTypeIndex == 1) {
          NSLog(@"Grid style view selected");
          _fromCollectionView = _collectionView2;
          _toCollectionView = _collectionView;
      }
  
      [_fromCollectionView removeFromSuperview];
  
      [_toCollectionView setFrame:[_superView bounds]];
      [_superView addSubview:_toCollectionView];
  
  }
  </code></pre>
  
  <p><strong>I've had two different suggestions via stackoverflow about a better way to do what I'm trying to do.</strong></p>
  
  <ol>
  <li>Use 2 <code>UICollectionViewFlowLayout</code>'s and switch between them instead of 2 <code>UICollectionView</code>'s.</li>
  <li>Return the appropriate custom <code>UICollectionViewCell</code> depending on what segment is selected.</li>
  </ol>
  
  <p>I feel the first way would be better. I would need to make the interface builder <code>UICollectionViewFlowLayout</code> an IBOutlet because the connected <code>UICollectionView</code> wasn't created programmatically. Then I'd create the second <code>UICollectionViewFlowLayout</code> programmatically. </p>
  
  <p>In my displayTypeSegmentSelected method I'd load one of the two <code>UICollectionViewFlowLayout</code>'s depending on the selected segment.</p>
  
  <p><strong>Single File Display would look like this:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/6FnYY.png" alt="enter image description here"></p>
  
  <p><strong>Grid Style Display would look like this:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/WRLWe.png" alt="enter image description here"></p>
  
  <p><strong>Question:</strong></p>
  
  <p>I think I have the right idea on the best way to go about doing what my original question asks and how to do it. However I'd profile an opinion and example from a more experience developer.
  How would you do this and can you show me a clear example I can go and mess around with?</p>
  
  <p>Kind Regards</p>