title: UIDynamics and Device Rotation
body: <p>If I add any kind of <code>UIDynamicBehavior</code> to my views, it completely breaks things when the device is rotated. Here's what it is in portrait (displaying correctly):</p>
  
  <p><img src="https://i.stack.imgur.com/1Ke6K.png" alt="Correct Layout"></p>
  
  <p>And here it is in landscape, all broke:<img src="https://i.stack.imgur.com/GkE7n.png" alt="Broken layout"></p>
  
  <p>I don't believe it's an autolayout issue because if I remove the calls to add the <code>UIDynamicBehavior</code> it works fine with no autolayout problems. No autolayout errors are ever thrown either. Here's the code:</p>
  
  <pre><code>@interface SWViewController () {
    UICollisionBehavior *coll;
    UIDynamicAnimator *dynamicAnimator;
  }
  
  @implementation SWViewController
  - (void)viewDidLoad {
    [super viewDidLoad];
    dynamicAnimator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
  }
  
  - (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self setupCollisions]; // commenting this out fixes the layout
  }
  
  - (void)setupCollisions {
    NSArray *dynamicViews = @[greenView];
    coll = [[UICollisionBehavior alloc] initWithItems:dynamicViews];    
    CGFloat topBound = CGRectGetMinY(greenView.frame);
    [coll addBoundaryWithIdentifier:@"top"
                          fromPoint:CGPointMake(0, h1)
                            toPoint:CGPointMake(CGRectGetWidth(greenView.frame), h1)];    
    [dynamicAnimator addBehavior:coll];
  }
  </code></pre>
  
  <p>If I override <code>didRotateFromInterfaceOrientation</code> I can see that the top boundary of <code>greenView</code> doesn't follow what autolayout says it should (again, removing the call to <code>setupCollisions</code> fixes this).</p>
  
  <p>The autolayout boundaries on <code>greenView</code> are:</p>
  
  <pre><code>height = 200
  trailing space to Superview = 0
  leading space to Superview = 0
  bottom space to Superview = 0
  </code></pre>