Swiping gestures in iPad
Is it possible to implement a solution that allows one to swipe in a certain way across the screen and then trigger an event of some kind to load another UIView for e.g.Wikipedia app
My problem is that I wan开发者_JAVA百科t it to be over my MKMapView - but I am guessing it would interfere with the map.
Does anyone have a simple code snippet?
As nduplessis said, UIGestureRecognizer will do it. It should be able to differentiate between dragging the map and performing the swipe gesture, so you should be fine.
Creating and adding the gesture recognizer:
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
swipeRight.delegate = self;
[mapView addGestureRecognizer:swipeRight];
Reacting to the gesture:
- (void)swipeRightAction:(UISwipeGestureRecognizer *)gestureRecognizer
{
//Switch views...(do this however you have been switching views)
[mapView.superview addSubview:wikipediaView];
[mapView removeFromSuperview];
}
You should be able to do this with UIGestureRecognizers
精彩评论