title: Adaptive UIPresentationController Based on View Size
body: <p>I'm moving over to <code>UIPresentationController</code> based presentations for my view controllers but have run into some confusion with the API.</p>
  
  <p>I have a custom sidebar style view controller presentation (similar to the <code>LookInside</code> WWDC 2014 demo code). </p>
  
  <p>This class cluster (<code>UIPresentationController</code>, <code>UIViewControllerTransitioningDelegate</code>, and <code>UIViewControllerAnimatedTransitioning</code>) presents a view controller as a sidebar from the edge of the screen on regular size class views, and presents the same view controller as full screen on compact size class views.</p>
  
  <p>Testing this on the Resizable iPad target shows the correct behaviour: I set the horizontal size class to "Compact" and my view controller switches from sidebar to full screen.</p>
  
  <p>However, I want more granularity. I would like to use the sidebar-style view controller presentation on iPhone 6 and 6+ when the device is in landscape orientation, and use the full-screen style presentation for all iPhones in portrait orientation.</p>
  
  <p>So in my method</p>
  
  <pre><code>- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id&lt;UIViewControllerTransitionCoordinator&gt;)coordinator
  </code></pre>
  
  <p>I implemented some logic to detect whether the sidebar will occupy too much of the screen, let's say I use the following condition:</p>
  
  <pre><code>//If my sidebar is going to occupy more than half the new width of the view...
  if( self.sidebarTransitionController.width &gt; size.width / 2.0 )
  {
      //Override the presentation controller's trait collection with Compact horizontal size class
      sidebarPresentationController.overrideTraitCollection = [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassCompact];
  }
  else
  {
      //Otherwise override the trait collection with Regular
      sidebarPresentationController.overrideTraitCollection = [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassRegular];
  
  }
  </code></pre>
  
  <p>However this does nothing. The documentation for <code>UIPresentationController.overrideTraitCollection</code> states:</p>
  
  <blockquote>
    <p>Use this property to specify any traits that you want to apply to the presented and presenting view controllers. The traits you specify override any existing traits currently in effect for the view controllers. The default value of this property is nil.</p>
    
    <p>Assigning a new value to this property causes the presentation controller to transition to the new set of traits, which could result in animations to the presented interface.</p>
  </blockquote>
  
  <p>Assigning the new value to the presentation controller does not cause my presented interface to change in any way. (Even if I assign the <code>overrideTraitCollection</code> when the <code>UIPresentationController</code> is created from within the <code>UIViewControllerTransitioningDelegate</code> object.) </p>
  
  <p>What am I missing? Is it possible to perform adaptive presentation with <code>UIPresentationController</code> on a more granular level?</p>