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 06-30-2011, 03:41 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Question Three-finger swipe

Hi,
I have a view that accepts one-finger touches for panning and two-finger touches for zooming. Now I want to add a three-finger gesture, but touchesBegan is seemingly not called when I tap with three fingers on the device. The code I have is below:
Code:
//Touches began
	touches = [touches setByAddingObjectsFromSet:[event allTouches]];
	//Not called with three fingers
	//One- and two-finger taps work
	if ([touches count] == 3)
	{
		NSLog(@"Began");
		stages = 1;
		tapCount = 3;
	}

//Touches moved
	//One and two fingers
	touches = [touches setByAddingObjectsFromSet:[event allTouches]];
	else if (tapCount == 3)
	{
		if ([[touches anyObject] locationInView:self].x > [[initialTouches anyObject] locationInView:self].x)
		{
			NSLog(@"moved");
			stages = 2;
		}
	}

//Touches ended
	touches = [touches setByAddingObjectsFromSet:[event allTouches]];
	//One and two fingers
	else if (tapCount == 3)
	{
		NSLog(@"Ended");
		if (stages == 2)
			if (self.delegate != nil)
				[self.delegate openAssistant:self];
	}
	tapCount = 0;
Has anyone encountered this problem before? If so, how can I fix it?
Thanks!
architectpianist is offline   Reply With Quote
Old 06-30-2011, 04:01 PM   #2 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 389
Esko2300 is on a distinguished road
Default

Read up on UIGestureRecognizerSwipe that should be all you need to know
Esko2300 is offline   Reply With Quote
Old 06-30-2011, 04:18 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 566
Noise is on a distinguished road
Default

I was reading up on swipe gestures yesterday. I believe you'll want to look in "numberOfTouches" or something along those lines. Follow Esko's link - the info is in there.
Noise is offline   Reply With Quote
Old 06-30-2011, 04:25 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Default

I tried this with the following code in the awakeFromNib method on the view:
Code:
if (assistOpener == nil)
{
	assistOpener = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(assistantOpened:)];
	assistOpener.numberOfTouchesRequired = 3;
	assistOpener.direction = UISwipeGestureRecognizerDirectionRight;
	[self addGestureRecognizer:assistOpener];
}
But, unfortunately it doesn't work.
architectpianist is offline   Reply With Quote
Old 06-30-2011, 04:45 PM   #5 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 389
Esko2300 is on a distinguished road
Default

just set a UISwipeGesturerecognizer object. Set it numberOfTouches equal to three. Then set it to the object you want to have the program respond to.
Esko2300 is offline   Reply With Quote
Old 06-30-2011, 04:48 PM   #6 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Default

Why, is there something I left out? assistOpener is the swipe gesture recognizer, and self is the view I want it on.
architectpianist is offline   Reply With Quote
Old 07-02-2011, 01:18 PM   #7 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 566
Noise is on a distinguished road
Default

Quote:
Originally Posted by architectpianist View Post
Why, is there something I left out? assistOpener is the swipe gesture recognizer, and self is the view I want it on.
I'm not quite understanding why you're putting it in awakeFromNib.

Take a look at the Developer Documentation on UISwipeGestureRecognizer - it's really clear on how to set it up, and it's quite easy.
Noise is offline   Reply With Quote
Reply

Bookmarks

Tags
finger, gesture, touch, touchesbegan

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: 338
8 members and 330 guests
apatsufas, chemistry, lendo, leostc, Leslie80, lzwasyc, MarkC, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

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