You should actually set the position of the UIView in your pan: selector. And since you are doing this in your AdvancedView class, and not outside, you need to get the view of the parent view ([self superview]), because the position is updated relative to the parent (containing) view. Try the following:
- (void)pan:(UIPanGestureRecognizer *)gesture { if ((gesture.state == UIGestureRecognizerStateChanged) || (gesture.state == UIGestureRecognizerStateEnded)) { CGPoint location = [gesture locationInView:[self superview]]; [self setCenter:location]; } }
Keep in mind that you need to make sure that your subclass representation allows the user to interact or recognize gestures will not work. Just enable it with [self setUserInteractionEnabled:YES] when you start browsing.
source share