could anyone tell me how to handle Pinch and pan gesture UIView inside UIScrollview. I have to display both 2 videos at the same time and can use pan and pinch gesture on it.So I keep both AVPlayer on each of its UIView. Then I put that UIView inside each of ScrollView. Now I need even when I pan or pinch that UIView it still keeps inside the UIScrollView's bound corner. Because when I panned it I can move it outside of the UIScrollview. Here is my code in github https://github.com/longnh2604/CheckVideoZoom.git
Pan gesture
- (IBAction)handlePan1:(UIPanGestureRecognizer *)sender
{
CGPoint translation = [sender translationInView:self.view];
sender.view.center = CGPointMake(sender.view.center.x + translation.x,
sender.view.center.y + translation.y);
[sender setTranslation:CGPointMake(0, 0) inView:self.view];
}
Pinch gesture
- (void)twoFingerPinch1:(UIPinchGestureRecognizer *)recognizer
{
static float initialDifference = 0.0;
static float oldScale = 1.0;
if (recognizer.state == UIGestureRecognizerStateBegan){
initialDifference = oldScale - recognizer.scale;
}
CGFloat scale = oldScale - (oldScale - recognizer.scale) + initialDifference;
viewVideo1.transform = CGAffineTransformScale(self.view.transform, scale, scale);
oldScale = scale;
}