Results 1 to 7 of 7

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Events: Swipes and Flicks

  1. #1
    Default Events: Swipes and Flicks
    hy,
    sorry to bother you all again

    I tried putting up events today. I managed to put up tap-events just fine, I can recognize taps, doubletaps, tripletaps, whatever.

    I encountered problems when trying to respond to a swipe gestures though.
    This is my code:

    Code:
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    	UITouch *touch = [touches anyObject];
    	if (touch.tapCount == 2 && touch.view == self) {
    		//Stuff that should be done on double-tap. this works fine.
    	}
    	if (touch.info == UITouchSwipedRight) {
                    //Everything in here is never executed
    		UILabel *test = [[UILabel alloc] initWithFrame:CGRectMake(100,100,100,100)];
    		test.text = @"Swiped to the right";
    		test.font = [UIFont systemFontOfSize:20];
    		[self addSubview:test];
    	}
    }
    the part that should be executed when a right-swipe is detected is never executed, no matter what I do. I also tried
    if (touch.info & UITouchSwipedRight)
    according to the iphone OS programming guide, though I don't really know if it does matter.
    why does this not work? The code is exactly the same as in the example in the iphone OS guide (chapter event handling) but it does not work.

    also: how would I detect flick gestures? because flicks are way easier to do by the user than swipes, so I would like to respond to flicks and swipes.

    thanks

  2. #2
    A swipe is a separate event from touches. There are a few samples up on the idevdocs.com sample code forum. There's a canHandleSwipes() you setup, as I recall.

  3. #3
    Quote Originally Posted by Cobra View Post
    A swipe is a separate event from touches. There are a few samples up on the idevdocs.com sample code forum. There's a canHandleSwipes() you setup, as I recall.
    thanks for your reply.

    mh, can't really find anything about it there, sorry.
    also, according to apples iphone OS development PDF, a swipe is also a touch. just a touch that has been moved in a specific direction. and normally that direction is stored in the info property of the touch, but when I try to determine whether or not a touch is a swipe it always returns false.

    I wrote a own little routine that detects swipes now that works with the finger-position, but that's not the best solution to be honest.

    PS: this is copied from apples PDF on how to determine a swipe:
    Code:
    - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
        UITouch *touch = [touches anyObject];
        if (touch.info & UITouchSwipedRight) {
            [self showPreviousImage];
        } else if (touch.info & UITouchSwipeLeft) {
            [self showNextImage];
        }
        return;
    }
    Last edited by BlackWolf; 2008-03-23 at 12:11 AM.

  4. #4
    Oh, are you using toolchain or sdk? My comments are about the open toolchain. I think they changed the behavior for the sdk interface.

  5. #5
    Quote Originally Posted by Cobra View Post
    Oh, are you using toolchain or sdk? My comments are about the open toolchain. I think they changed the behavior for the sdk interface.
    oh, I thought they were quite alike. in that case: sdk.
    but thanks for trying

  6. #6
    BlackWolf,
    How are you using touch.info and UITouchSwipedRight ?

    I don't find these references in my SDK header files ?!

  7. #7

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •