title: Dragging UIView with UIAttachmentBehavior and auto layout constraints
body: <p>I have a <code>UIScrollView</code> set up in IB with auto layout that contains an <code>UIImageView</code>. You can have a look at the Github repository of Evgenii to see how it is set up: <a href="https://github.com/evgenyneu/ios-imagescroll" rel="nofollow">https://github.com/evgenyneu/ios-imagescroll</a></p>
  
  <p>The scrollview is used to enable pinch-to-zoom. I want to be able to move the scrollview around with a <code>UIPanGestureRecognizer</code> using the new <code>UIAttachmentBehavior</code>. This works well without auto layout, but with auto layout enabled the scroll view content flickers and the scroll view gets distorted.</p>
  
  <pre><code>- (void)handlePanGesture:(id)sender
  {
      CGPoint p = [_panGesture locationInView:self.view];
  
      if (_panGesture.state == UIGestureRecognizerStateBegan) {
          self.scrollView.userInteractionEnabled = NO;
  
          CGPoint center = self.view.center;
          UIOffset offset = UIOffsetMake(p.x - center.x, p.y - center.y);
  
          _attachBehavior = [[UIAttachmentBehavior alloc] initWithItem:self.scrollView offsetFromCenter:offset attachedToAnchor:p];
          [_animator addBehavior:_attachBehavior];
      } else if (_panGesture.state == UIGestureRecognizerStateChanged) {
          _attachBehavior.anchorPoint = p;
      }
  }
  </code></pre>
  
  <p>My guess is that the constraints set to the scroll- and imageViews interfere with the attachment behavior, also the <code>contentSize</code> of the scrollView depends on its content and the constraints of that.</p>
  
  <p>Any idea how to get that working would be appreciated.</p>
  
  <p>Edit: Tested with a normal view instead of the scrollView/imageView combination and the same problem exists. So it has to be an issue with using <code>UIAttachmentBehavior</code> for the panning purpose with auto layout.</p>