How can I switch views vertically using swipe gestures ?
This gesture is also called tap and hold and can be used to activate special menus. A swipe is is when you touch and slide your finger across the screen. You can swipe quickly or slowly, depending on what you're doing on your phone or tablet.
Open your device Settings and select Display > Navigation bar. Under Navigation type, tap Swipe gestures from the two options. To customize swipe gestures, tap More options, then select from Swipe from buttons and Swipe from sides and bottom.
I found my answer. I am posting the code for your reference. Thanks :-)
in viewDidLoad
UISwipeGestureRecognizer *swipeGesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedScreendown:)] autorelease];
swipeGesture.numberOfTouchesRequired = 1;
swipeGesture.direction = UISwipeGestureRecognizerDirectionDown;
[m_pImageView addGestureRecognizer:swipeGesture];
Now
- (void)swipedScreendown:(UISwipeGestureRecognizer*) swipeGesture {
m_pViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
CATransition *transition = [CATransition animation];
transition.duration = 0.75;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromBottom;
transition.delegate = self;
[self.view.layer addAnimation:transition forKey:nil];
[self.view addSubview:PadViewController.view];
}
If you need some more clarification please post here.
Implement this (didload)
//........towards right Gesture recogniser for swiping.....//
UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
rightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[rightRecognizer setNumberOfTouchesRequired:1];
[urView addGestureRecognizer:rightRecognizer];
[rightRecognizer release];
//........towards left Gesture recogniser for swiping.....//
UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];
leftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[leftRecognizer setNumberOfTouchesRequired:1];
[urView addGestureRecognizer:leftRecognizer];
[leftRecognizer release];
Then This:
- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
//Do moving
}
- (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
// do moving
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With