Okay so here is the problem I'm running into:
I am attempting to switch from one viewController
that I named MenuViewController
which contains my menu (obviously). I have a separate viewController
named ViewController
that contains my mapView
. I would like to be able to double finger swipe left
from my MenuViewController
over to my mapView
.
I'm not exactly sure where to start.
Also, I am using xib files, and not the storyboard. Running iOS 6.
Right-click the control or object in your current view controller. Drag the cursor to the view controller you want to present. Select the kind of segue you want from the list that Xcode provides.
One of the most common gestures you will use on your smartphone or tablet is a swipe. That's where you place your finger on the screen and slide it across the surface. In most instances, the item under your finger will move.
Swipe right or left along the bottom edge of the screen to quickly switch between open apps. See Switch between open apps on iPhone.
A swipe gesture recognizer detects swipes in one of four directions, up , down , left , and right . We set the direction property of the swipe gesture recognizer to down . If the user swipes from the top of the blue view to the bottom of the blue view, the swipe gesture recognizer invokes the didSwipe(_:)
UISwipeGestureRecognizer *swipeLeftGesture=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)];
[self.view addGestureRecognizer:swipeLeftGesture];
swipeLeftGesture.direction=UISwipeGestureRecognizerDirectionLeft;
-(void)handleSwipeGesture:(UIGestureRecognizer *) sender
{
NSUInteger touches = sender.numberOfTouches;
if (touches == 2)
{
if (sender.state == UIGestureRecognizerStateEnded)
{
//Add view controller here
}
}
}
once go through this,
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleleftSwipe:)];
swipeLeft.numberOfTouchesRequired = 1;//give required num of touches here ..
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft.delegate = (id)self;
[self. view addGestureRecognizer:swipeLeft];
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handlerightSwipe:)];
swipeRight.numberOfTouchesRequired = 1;//give required num of touches here ..
swipeRight.delegate = (id)self;
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRight];
now define swipe methods like below:
-(void)handleleftSwipe:(UISwipeGestureRecognizer *)recognizer{
//Do ur code for Push/pop..
}
-(void)handlerightSwipe:(UISwipeGestureRecognizer *)recognizer{
//Do ur code for Push/pop..
}
Hope it helps you...
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