Reputation: 19507
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 want it to be over my MKMapView - but I am guessing it would interfere with the map.
Does anyone have a simple code snippet?
Upvotes: 0
Views: 429
Reputation: 6270
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];
}
Upvotes: 2