Here is the code from Apple's MoveMe project the key is to do this in the touchesMoved
method. It allows the UIView
(PlacardView
) to see the touch and move wherever the user's touch goes. Hope this helps.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
// If the touch was in the placardView, move the placardView to its location
if ([touch view] == placardView) {
CGPoint location = [touch locationInView:self];
placardView.center = location;
return;
}
}