Search code examples
iphoneuiviewdrag-and-dropmpmovieplayer

Moving the MPMoviePlayer across the screen using drag and drop


I need to pinch size the MPMoviePlayer and move it across the screen. I have been able to achieve the first task by putting the player to an UIView and applying pinch gesture to the UIView. Now I need to move the video. Anyone know a possible solution? Thanks in advance.


Solution

  • As I understand it, your problem is to NOT move the player across the screen while pinching, but move it if the user has only one finger touching the screen.

    Try checking for touch, and only following with action on the event if it's not a multiple touch.

    Use this gestureRecognizer: shouldRecognizeSimultaneouslyWithGestureRecognizer: method, to allow several gestures.

    - (BOOL)gestureRecognizer: (UIGestureRecognizer *) gestureRecognizer      
            shouldRecognizeSimultaneouslyWithGestureRecognizer:
                               (UIGestureRecognizer *) otherGestureRecognizer
    {
        if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]] 
    || [gestureRecognizer isKindOfClass:[UIPinchGestureRecognizer class]]
    || [otherGestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]
    || [otherGestureRecognizer isKindOfClass:[UIPinchGestureRecognizer class]]) 
     {
         return YES;
     }
    return NO;
    }
    

    Some help might come from the documentation on Gesture Recognizers.