title: Use updateViewConstraints() to mimic native iOS camera interface behavior on orientation change
body: <p>This is the third method I've tried to use to create an interface that smoothly mimics the behavior you see in the native iOS camera interface. If you re-orient the device in the iOS camera interface, you'll notice the interface mostly stays stationary, but the objects that have an "up" orientation spin in place to the correct orientation.</p>
  
  <p>Things that haven't worked out:</p>
  
  <ol>
  <li><p>Using transformations on the individual elements that need to rotate. This works, but the elements don't pivot with the smooth animations you see in the native iOS app and it leads to some annoying issues. Specifically, part of my interface allows users to share without leaving this interface, but when the sharing view presents, it comes from the wrong place, then gets rotated, and ends up off-center. For details on how to do this, see my question about this topic as well as my answer <a href="https://stackoverflow.com/questions/33027948/">here</a>.</p></li>
  <li><p>Using viewWillTransitionToSize to counteract the rotation of the interface (with animation). To do this, you have the non-rotating view rotate the opposite direction of the orientation change, then have the icons that need to pivot in place rotate in the opposite direction of the non-rotating view. Everything gets animated to synchronize with the superview's default animation as it re-orients. It took me forever to get this working, but I finally worked it out. <a href="https://stackoverflow.com/questions/33132977/">Here is a separate thread on that topic</a>. I still feel this is a sort of messy way to accomplish this though and would like to see if there's a better way to do it.</p></li>
  </ol>
  
  <p><strong>Using updateViewConstraints() to achieve this behavior</strong></p>
  
  <p>I'm convinced this will work and that it's probably the cleanest solution. But I can't get it working. Here's the basic idea in the proof of concept I'm tinkering with first... When the app first loads, start out with a constraint that links a subview to the top edge of its parent and another to center it along the x-axis. If the user rotates the device to the left (landscape-right orientation), then the subview gets a new constraint to tie it to what is now the left edge of the parent and centered along what is now the y-axis.</p>
  
  <p>I have a storyboard that does the initial layout. As far as I can tell, nothing I set in updateViewConstraints ends up doing anything. Below is the main section of code I'm working with or you can <a href="https://github.com/jreikes/Rotation-Test" rel="nofollow noreferrer">download the Xcode project I'm using as a POC here</a>.</p>
  
  <pre><code>override func updateViewConstraints() {
      //northView.removeConstraints(northView.constraints)
      //northView.bounds.size = CGSizeMake(25, 25)
      //northView.frame.size = CGSizeMake(25, 25)
  
      switch UIDevice.currentDevice().orientation {
      case .LandscapeLeft:
          northView.rightAnchor.constraintEqualToAnchor(blueBackground.rightAnchor, constant: 20)
          northView.centerYAnchor.constraintEqualToAnchor(blueBackground.centerYAnchor)
      case .LandscapeRight:
          northView.leftAnchor.constraintEqualToAnchor(blueBackground.leftAnchor, constant: 20)
          northView.centerYAnchor.constraintEqualToAnchor(blueBackground.centerYAnchor)
      case .PortraitUpsideDown:
          northView.bottomAnchor.constraintEqualToAnchor(blueBackground.bottomAnchor, constant: 20)
          northView.centerXAnchor.constraintEqualToAnchor(blueBackground.centerXAnchor)
      default:
          northView.topAnchor.constraintEqualToAnchor(blueBackground.topAnchor, constant: 20)
          northView.centerXAnchor.constraintEqualToAnchor(blueBackground.centerXAnchor)
      }
      super.updateViewConstraints()
  }
  </code></pre>
  
  <p>Anyone know how to make this work using this method?</p>