Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-14-2009, 01:35 PM   #1 (permalink)
Registered Member
 
DenVog's Avatar
 
Join Date: Jan 2009
Location: Silicon Valley, USA
Posts: 624
DenVog is on a distinguished road
Question Multiple Swipes Not Recognized

I am trying to recognize when two fingers are being swiped simultaneously. I started with the "Swipes" sample code from the Beginning iPhone Development Book. Run by itself it seems to work fine. Once I integrate it into my application, it only can recognize a single finger swipe.

I have triple checked that I pulled over the relevant code. I've tried both the simulator and my phone (same results). It can recognize and differentiate between a horizontal or vertical swipe. It doesn't recognize anything more than a single finger. Doesn't produce any errors or warnings.

I thought maybe I was obscuring the swipe detection with a label, graphic, or view, but I suspect if that were the case it wouldn't detect be detecting a single swipe.

I also tried commenting out a repeating animation that I have, thinking maybe it was interrupting the detection of a second finger. That didn't change anything.

Been struggling with this off and on for a few days now. Any suggestions would be greatly appreciated.

PS-Based on the sample code, the output from detecting multiple swipes is an addition to a text string displayed in a label. It will say "double" or "triple" in addition to "vertical swipe detected". So perhaps I should clarify that I am not seeing a result that displays the "double" or "triple" text output in this label, and thus assuming the extra swipe is not being detected.

Last edited by DenVog; 02-14-2009 at 01:49 PM. Reason: Added PS Clarification
DenVog is offline   Reply With Quote
Old 02-15-2009, 06:23 PM   #2 (permalink)
Registered Member
 
DenVog's Avatar
 
Join Date: Jan 2009
Location: Silicon Valley, USA
Posts: 624
DenVog is on a distinguished road
Default

No one else has run into this? I'd really appreciate any insight that could be shared. Quite frustrating and I've pretty much exhausted the troubleshooting paths I can think of. Thanks for any help.
DenVog is offline   Reply With Quote
Old 02-15-2009, 06:31 PM   #3 (permalink)
Registered Member
 
tkilmer's Avatar
 
Join Date: May 2008
Posts: 583
tkilmer is an unknown quantity at this point
Default

can you post your code?
tkilmer is offline   Reply With Quote
Old 02-15-2009, 06:45 PM   #4 (permalink)
Registered Member
 
DenVog's Avatar
 
Join Date: Jan 2009
Location: Silicon Valley, USA
Posts: 624
DenVog is on a distinguished road
Default

Quote:
Originally Posted by tkilmer View Post
can you post your code?
I did not know if it would be cool for me to post the code here, as it's basically cut-and-paste from the Beginning iPhone Development Book Chapter 13 Swipes sample that is already online.

Beyond those chunks, I'm not sure what to post short of putting my whole project up here. Is there something in particular I can share that would help? Something that would cause a conflict, interrupt, and/or the ordering of statements?

Thanks for your attention.
DenVog is offline   Reply With Quote
Old 02-15-2009, 07:21 PM   #5 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 9
walaber is on a distinguished road
Default

Quote:
Originally Posted by DenVog View Post
I did not know if it would be cool for me to post the code here, as it's basically cut-and-paste from the Beginning iPhone Development Book Chapter 13 Swipes sample that is already online.

Beyond those chunks, I'm not sure what to post short of putting my whole project up here. Is there something in particular I can share that would help? Something that would cause a conflict, interrupt, and/or the ordering of statements?

Thanks for your attention.
make sure you have your view set to receive multi-touch events, otherwise the iPhone will only send you info about the first finger... if you're using Interface Builder, it's a checkbox for the view. otherwise you can do it in code as well.
walaber is offline   Reply With Quote
Old 02-15-2009, 07:50 PM   #6 (permalink)
Registered Member
 
DenVog's Avatar
 
Join Date: Jan 2009
Location: Silicon Valley, USA
Posts: 624
DenVog is on a distinguished road
Default

Quote:
Originally Posted by walaber View Post
make sure you have your view set to receive multi-touch events, otherwise the iPhone will only send you info about the first finger... if you're using Interface Builder, it's a checkbox for the view. otherwise you can do it in code as well.
Ha! That was it. For all the poking, searching, and trial and error I did in my code, it was a checkbox in interface builder. I feel very silly, but am grateful to know the answer. Thanks very much for taking time to respond.

What's the saying about the most obvious solution?
DenVog is offline   Reply With Quote
Old 02-15-2009, 11:55 PM   #7 (permalink)
Mobile Application Dev.
 
Join Date: Oct 2008
Location: Bangalore, india
Posts: 362
mpramodjain is on a distinguished road
Default Without IB,...

Quote:
Originally Posted by DenVog View Post
Ha! That was it. For all the poking, searching, and trial and error I did in my code, it was a checkbox in interface builder. I feel very silly, but am grateful to know the answer. Thanks very much for taking time to respond.

What's the saying about the most obvious solution?
Do anyone know how to achieve this , without using IB.
mpramodjain is offline   Reply With Quote
Old 04-25-2009, 04:21 AM   #8 (permalink)
New Member
 
Join Date: Feb 2009
Posts: 2
Cyborg is on a distinguished road
Default

Quote:
Originally Posted by mpramodjain View Post
Do anyone know how to achieve this , without using IB.
For example in the init method of your view do this:
Code:
[self setMultipleTouchEnabled:YES];
Cyborg is offline   Reply With Quote
Old 09-28-2009, 03:39 PM   #9 (permalink)
iPhone App Developer
 
Join Date: Jun 2009
Posts: 25
ccctennis is on a distinguished road
Default It works!

I sort of forgot about this thread for a while, but finally came back to it. I did get the multi-fingered swipes to work. I am guessing that there is a much easier way to do this, but apple has no documentation for it .

Here is the viewController.h file

Code:
//
//  TwoFingerSwipe.h
//  
//
//  Created by Cameron C Cohen on 9/2/09.
//  Copyright 2009 CCC Development, LLC. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface TwoFingerSwipe : UIViewController {

    CGPoint touchDownLocation;
    CGPoint touchUpLocation;
}
@property (nonatomic) CGPoint touchUpLocation;
@property (nonatomic) CGPoint touchDownLocation;
- (void) detectSwipe;


@end
And here is the viewController.m file

Code:
//
//  TwoFingerSwipe.m
//  
//
//  Created by Cameron C Cohen on 9/2/09.
//  Copyright 2009 CCC Development, LLC. All rights reserved.
//

#import "TwoFingerSwipe.h"


@implementation TwoFingerSwipe
@synthesize touchUpLocation, touchDownLocation;

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"touches began");
    //create a touch
    UITouch *touchDown = [touches anyObject];
    //only detect touch if there is two fingers
        if ([touches count] == 2)
        {
            NSLog(@"two fingers touched");
            //create a CGPoint which gives us the X and Y location of the touch
                touchDownLocation = [touchDown locationInView:self.view];
        }
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"touches ended");
    //create a touch
    UITouch *touchUp = [touches anyObject];
    //only detect touch if there are two fingers
    if ([touches count] == 2) {
        NSLog(@"Two fingers ended");
        //create CGPoint that gives us the X and Y values of the touch
        touchUpLocation = [touchUp locationInView:self.view];
        [self detectSwipe];

    }
        
}

//create the code that detects if there is a swipe. there is probably an easier way
//to do this, but this is the only way I know of.
- (void) detectSwipe {
    if (touchDownLocation.y >= (touchUpLocation.y - 50) && touchDownLocation.y <= (touchUpLocation.y + 50)) { 
        if (touchUpLocation.x > (25 + touchDownLocation.x)) {
            NSLog(@"swipe right");
        }
        else if (touchUpLocation.x < (25 + touchDownLocation.x)) {
            NSLog(@"Swipe left");
        }
    }
}

@end
I think that the op must have found some other way to do this.
__________________
11 year old that makes iPhone apps.
www.cccdevelopment-llc.com
iSketch iTunes Link
ccctennis is offline   Reply With Quote
Reply

Bookmarks

Tags
swipes

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 327
5 members and 322 guests
Anwerbl, guusleijsten, HowEver, LEARN2MAKE, mottdog
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,879
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:39 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0