Skip to content

Instantly share code, notes, and snippets.

@sherbondy
Created March 4, 2011 17:45
Show Gist options
  • Save sherbondy/855367 to your computer and use it in GitHub Desktop.
Save sherbondy/855367 to your computer and use it in GitHub Desktop.
/*
Create a swipe gesture recognizer to recognize right swipes (the default).
We're only interested in receiving messages from this recognizer, and the view will take ownership of it, so we don't need to keep a reference to it.
*/
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[self.view addGestureRecognizer:recognizer];
[recognizer release];
/*
Create a swipe gesture recognizer to recognize left swipes.
Keep a reference to the recognizer so that it can be added to and removed from the view in takeLeftSwipeRecognitionEnabledFrom:.
Add the recognizer to the view if the segmented control shows that left swipe recognition is allowed.
*/
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
self.swipeLeftRecognizer = (UISwipeGestureRecognizer *)recognizer;
swipeLeftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
if ([segmentedControl selectedSegmentIndex] == 0) {
[self.view addGestureRecognizer:swipeLeftRecognizer];
}
self.swipeLeftRecognizer = (UISwipeGestureRecognizer *)recognizer;
[recognizer release];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment