Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Views Navigation Using Swipe Gesture

How can I switch views vertically using swipe gestures ?

like image 504
Akshay Avatar asked Jun 13 '11 04:06

Akshay


People also ask

What is the swipe gesture?

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.

How do I activate gesture navigation on Samsung?

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.


2 Answers

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.

like image 119
Akshay Avatar answered Sep 30 '22 05:09

Akshay


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
}
like image 31
rptwsthi Avatar answered Sep 30 '22 05:09

rptwsthi