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 09-09-2011, 05:09 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 14
TronPlayer is on a distinguished road
Default Help understanding UIGestureRecognizer

Could someone please tell me why there are 4 events called sequentially in UIGestureRecognizer? I was initially thinking that the events being passed were UITouchesBegan, UITouchesEnded, etc but now I am unsure. I need to call a function in UIGestureRecognizer a single time when the user initially touches an object. Could someone post a sample solution?


- (BOOL)gestureRecognizerUIGestureRecognizer *)gestureRecognizer shouldReceiveTouchUITouch *)touch {
NSLog(@"Triggered");
}
TronPlayer is offline   Reply With Quote
Old 09-09-2011, 05:18 PM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

To receive a message that something has been touched, you need to add a target and a selector to the UIGestureRecognizer. The method you posted is whether the recognizer should message the target with the specified method.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 09-09-2011, 09:52 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 14
TronPlayer is on a distinguished road
Default

The app needs to detect rapid, consecutive touches on an UIImageView object with two fingers alternating back and forth. Using a single finger the events come trough TouchesBegan just fine. However, with two fingers using the same rapid back and forth motion the events discontinue. I am assuming that at this point the system is detecting a gesture instead. Do you have any suggestions on how to remedy this?
TronPlayer is offline   Reply With Quote
Old 09-09-2011, 09:55 PM   #4 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

I would see maybe if it detecting a double tap. Set up a gesture recognizer for that and if it turns out that it is, just have 2 gesture recognizers that call the same method.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 09-09-2011, 10:11 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 14
TronPlayer is on a distinguished road
Default

It's not detecting a doubletap but rather once two fingers happen to touch the UIImageView at the same time the events become sporatic. Is there anyway to turn off multitouch or equivilant to prevent this?
TronPlayer is offline   Reply With Quote
Old 09-09-2011, 10:21 PM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

I haven't gone too complicated with gesture recognizers, but you should be able to look at the touches and the state to see what is happening. Ex:

Code:
- (void)handleTapGesture:(UIGestureRecognizer *)gestureRecognizer
{
   UIGestureRecognizerState state = [gestureRecognizer state];
...
I'm going to make a guess that each time you change fingers, you're canceling the previous touch. Not sure. But taking a look at this state, and using some of the other UIGestureRecognizer instance methods will help you to figure out what is happening.

I'm also going to make a guess that you'll need to add 2 subviews to your image view, so that each finger is touching one view and each view has its own recognizer, and then handling things that way. Not sure.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 09-10-2011, 03:38 AM   #7 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

If you just need notifications of when a finger first touches the screen, you could implement the old

Code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
baja_yu is offline   Reply With Quote
Reply

Bookmarks

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: 411
10 members and 401 guests
apatsufas, Eclectic, fiftysixty, JackReidy, jeroenkeij, teebee74, tim0504, UMAD, yomo710, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

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