1

How do i implement and code for recognizing swipes across the screen, and also making it so that if it swipes on a uiimageview then things happen, // code, how can i do this? THanks

2 Answers 2

3

Use UISwipeGestureRecognizer. Something like this to detect a swipe on imageView:

UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(imageSwiped:)];
swipe.direction = UISwipeGestureRecognizerDirectionRight;
[imageView addGestureRecognizer:swipe];
[swipe release];

Then define a method - (void)imageSwiped:(UISwipeGestureRecognizer *)sender and react to the swipe there.

2
  • but one more question, what if it can be any direction, should I use this operater: ||
    – user842059
    Jul 14, 2011 at 20:12
  • You shoudln't use || ! UISwipeGestureRecognizerDirection is enum composed by bit shited numbers. So you can combine but using the bit OR operator, which is | (single).
    – user756245
    Jul 14, 2011 at 20:54
0

I suggest you use a UISwipeGestureRecongizer for it, unless you have a very specific gesture to recongize.

Try reading out : Event Handling Guide for iOS from Apple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.