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 10-09-2010, 09:18 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 31
pete42 is on a distinguished road
Default LongPressGestureRecognizer problems

I created calendar view with buttons and i am trying to use long press to implement local notifiactions. For example, the user taps on the btn for 2 seconds, a uialertview pops up and asks to set notification.

my problem is with the first part. I need a way to identify which gesture recognizer is tapped. I know how to do this with tags for buttons but I can't seem to figure out how it works with gesture recongizers.

my buttons and gesture recognizers are dynamically created and assigned.

If anyone has figured it out your help would be greatly appreciated.

here is an image of the view to give you an idea. the red and blue squares are buttons.

pete42 is offline   Reply With Quote
Old 10-10-2010, 06:00 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 204
marciokoko is on a distinguished road
Default Longpress

I'd like to know how to code the long press of a button; the tap vs the 2-sec press.


Quote:
Originally Posted by pete42 View Post
I created calendar view with buttons and i am trying to use long press to implement local notifiactions. For example, the user taps on the btn for 2 seconds, a uialertview pops up and asks to set notification.

my problem is with the first part. I need a way to identify which gesture recognizer is tapped. I know how to do this with tags for buttons but I can't seem to figure out how it works with gesture recongizers.

my buttons and gesture recognizers are dynamically created and assigned.

If anyone has figured it out your help would be greatly appreciated.

here is an image of the view to give you an idea. the red and blue squares are buttons.

__________________
Mars
www.santiapps.com
www.gea-hn.com
mba-i4
marciokoko is offline   Reply With Quote
Old 10-10-2010, 10:41 AM   #3 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 31
pete42 is on a distinguished road
Default

Quote:
Originally Posted by marciokoko View Post
I'd like to know how to code the long press of a button; the tap vs the 2-sec press.
Code:
UILongPressGestureRecognizer *longPressGR;
UIButton *btn;

	UIGestureRecognizer *recognizer;
		recognizer = [[ UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
		recognizer.delegate = self;
		
		longPressGR = (UILongPressGestureRecognizer *)recognizer;
		longPressGR.minimumPressDuration = 2.0;
				
		[btn addGestureRecognizer:longPressGR];

-(void) handleLongPress:(UILongPressGestureRecognizer *)recognizer  {
   //do stuff here
}
The Buttons's action doesn't get called. I use touchUpInside so it works. It might not work with touchDown. Just try it you'll see that it works.

If you would know how to differentiation recognizers with tags or something, that would be great.
pete42 is offline   Reply With Quote
Reply

Bookmarks

Tags
gesture, loop, problem, recognizer

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: 348
10 members and 338 guests
alexP, gordo26, headkaze, mistergreen2011, nobstudio, Objective Zero, rayjeong, revg, Sloshmonster, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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