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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 03-12-2010, 01:19 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 3
Default how to track double tap event on Uitableview

Hi,
i am new bie in iphone development. I am facing a problem in tracking a double tap event on uitable view.

In my application there is uitable view in which I am using Uitable view cell for making as per requirment. I have written touch event in the subview subcell.m
the code is like this
- (void)touchesBeganNSSet *)touches withEventUIEvent *)event
{
NSUInteger numTaps = [[touches anyObject] tapCount];
if (numTaps < 2) {
//[self performSelector:@selector(doThis) withObject:nil afterDelay: 0.5 ];

[self.nextResponder touchesEnded:touches withEvent:event];
} else {
if(numTaps == 2) {

NSLog(@"2 taps - ");

tapcounter=@"today";
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(gestureDidSwipeRight) name:@"eventName" object:nil];
[self performSelector:@selector(doubleTap) withObject:nil afterDelay: 0.5 ];
}

if(numTaps == 3){
NSLog(@"3 taps - Previous");

[NSObject cancelPreviousPerformRequestsWithTarget:self];

// [self doSomethingElseCompletely];

}
}


[super touchesBegan:touches withEvent:event];
}


-(void)gestureDidSwipeRight
{
NSLog(@"notification found");
}

Its working fine and showing the notification. But I want this notification in super view that is the main tableview.

Is there any other way to track the double tap event?
Thanks in advance.
Ajeet is offline   Reply With Quote
Old 03-13-2010, 05:20 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 4,814
Default Use didSelectRowAtIndexPath:

Quote:
Originally Posted by Ajeet View Post
Hi,
i am new bie in iphone development. I am facing a problem in tracking a double tap event on uitable view.

In my application there is uitable view in which I am using Uitable view cell for making as per requirment. I have written touch event in the subview subcell.m
the code is like this
- (void)touchesBeganNSSet *)touches withEventUIEvent *)event
{
NSUInteger numTaps = [[touches anyObject] tapCount];
if (numTaps < 2) {
//[self performSelector:@selector(doThis) withObject:nil afterDelay: 0.5 ];

[self.nextResponder touchesEnded:touches withEvent:event];
} else {
if(numTaps == 2) {

NSLog(@"2 taps - ");

tapcounter=@"today";
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(gestureDidSwipeRight) name:@"eventName" object:nil];
[self performSelector:@selector(doubleTap) withObject:nil afterDelay: 0.5 ];
}

if(numTaps == 3){
NSLog(@"3 taps - Previous");

[NSObject cancelPreviousPerformRequestsWithTarget:self];

// [self doSomethingElseCompletely];

}
}


[super touchesBegan:touches withEvent:event];
}


-(void)gestureDidSwipeRight
{
NSLog(@"notification found");
}

Its working fine and showing the notification. But I want this notification in super view that is the main tableview.

Is there any other way to track the double tap event?
Thanks in advance.

You can probably cheat and use the table view delegate method -didSelectRowAtIndexPath.

Write code in that method to record the time of a tap and check for a second tap within a short interval (~0.3 - 0.5 seconds). If you get two didSelectRowAtIndexPath within the time interval, treat it as a double-tap.

I use this method in one of the apps I've written and it works pretty well.

Failing that, you will probably have to pass a pointer to you table view controller to your custom cell and have the cell's touch handling method send a message to the table view controller.


Regards,

Duncan C
WareTo
Duncan C is offline   Reply With Quote
Old 03-15-2010, 08:58 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 3
Question Reply

Thanks for your reply. It will be very helpfull if you post some code what you suggested to do.

Thanks again.


Quote:
Originally Posted by Duncan C View Post
You can probably cheat and use the table view delegate method -didSelectRowAtIndexPath.

Write code in that method to record the time of a tap and check for a second tap within a short interval (~0.3 - 0.5 seconds). If you get two didSelectRowAtIndexPath within the time interval, treat it as a double-tap.

I use this method in one of the apps I've written and it works pretty well.

Failing that, you will probably have to pass a pointer to you table view controller to your custom cell and have the cell's touch handling method send a message to the table view controller.


Regards,

Duncan C
WareTo
Ajeet is offline   Reply With Quote
Reply

Bookmarks

Tags
double, event, tap, uitableview

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: 274
20 members and 254 guests
ADY, Bertrand21, Dani77, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, jimbo, macquitzon216, MACralik, mer10, NSeven, prchn4christ, Rudy, silverwiz, spiderguy84, Sunny46
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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