title: Drag UIView between UIViews
body: <p>I have a UIView object X that is contained in an UIView object A. I want to be able to touch X and remove it from object A and move it into object B (another UIView). Both Object A &amp; B are inside of the same super UIView.</p>
  
  <pre><code>  A        B
  _____    _____
  |   |    |   |
  | X | -&gt; |   |
  |___|    |___|
  </code></pre>
  
  <p>This is what I have so far.</p>
  
  <pre><code>@implementation X_UIView
  
  float deltaX;
  float deltaY;
  
  - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
      [self.superview.superview addSubview:self]; //pop dragged view outside of container view
  
      CGPoint beginCenter = self.center;
  
      UITouch * touch = [touches anyObject];
      CGPoint touchPoint = [touch locationInView:self.superview];
  
      deltaX = touchPoint.x - beginCenter.x;
      deltaY = touchPoint.y - beginCenter.y;
  }
  
  - (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
      UITouch * touch = [touches anyObject];
      CGPoint touchPoint = [touch locationInView:self.superview];
  
      // Set the correct center when touched 
      touchPoint.x -= deltaX;
      touchPoint.y -= deltaY;
  
      self.center = touchPoint;
  }
  
  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
      //discover view that event ended was over and add self as a subview.
  }
  
  @end
  </code></pre>