-2

I am working on and app in which i have to take user to next view if user swipe next. Simply swipe gesture working dine.

But the problem is a little of left swipe take the user to next view.

What i want to implement is to make user see pulling next view by itself and next view coming over to the present view according to the thumb swipe speed. Something like shown in the screenshot

enter image description here

Parv Bhasker
  • 1,773
  • 1
  • 20
  • 39

2 Answers2

2

See that library

https://github.com/zhxnlai/ZLSwipeableView

The same thing happening , if a required velocity is not there than card is not discarded , go to ZLSwipeableView and you can find code there , the hint you needed , like that

     CGPoint velocity = [recognizer velocityInView:self];

     CGFloat velocityMagnitude = sqrt(pow(velocity.x,2)+pow(velocity.y,2));

     CGPoint normalizedVelocity = CGPointMake(velocity.x/velocityMagnitude, velocity.y/velocityMagnitude);
Mandeep Kumar
  • 776
  • 4
  • 18
  • thanks for the responce... Actually what i mean by velocity is --> user using is thumb swiping from the right corner of the screen to the left and next view is seeing pulling with the thumb and with the same velocity. – Parv Bhasker Feb 16 '16 at 12:24
  • yes no problem , just decide a thresold for the velocity and as soon as velocity is over that then replace by other view , you can use CAAnimation for that – Mandeep Kumar Feb 16 '16 at 12:30
  • you will have to set the animation.speed = 3.0 that was on the time of swiing – Mandeep Kumar Feb 16 '16 at 12:36
  • just a quick question-- as when user start swiping from right to left then i have to show the next view coming out from the right side and moving to the left.....how i suppose to do that .... – Parv Bhasker Feb 16 '16 at 12:36
  • The UIPanGestureRecognizer has a velocityInView proerty that you may find of use. Docs are https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPanGestureRecognizer_Class/index.html – Mandeep Kumar Feb 16 '16 at 12:38
  • CATransition *transition = [CATransition animation]; transition.duration = 0.4; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = kCATransitionPush; transition.subtype = kCATransitionFromLeft; [self.view.window.layer addAnimation:transition forKey:nil]; [self presentViewController:self.vcMenuObj animated:NO completion:nil]; – Mandeep Kumar Feb 16 '16 at 12:44
  • thanks @Mandeep Kumar - I am implementing the same. Will discuss with you if face any issue. – Parv Bhasker Feb 16 '16 at 13:07
0

Use UIpanGestureRecognizer, track the area swiped and move to next Screen or you have to use UIContainer

Durga Vundavalli
  • 1,790
  • 22
  • 26