RSS

UILongPressGestures

23 Apr

Q ) How to Add UILonggestures to UIButton ?
Ans :

you have to add this function into your class

– (void)longPressHandler:(UILongPressGestureRecognizer *)gestureRecognizer {
if(UIGestureRecognizerStateBegan == gestureRecognizer.state) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”” message:@”Are you sure, you want to delete QR Code?” delegate:self cancelButtonTitle:@”Cancel” otherButtonTitles:@”Ok”,nil];
alert.tag = 1000;
[alert show];
[alert release];
}

}

And add gestures to uibutton this way

longpressGestureIDBadge = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)];
longpressGestureIDBadge.minimumPressDuration = 1;
[longpressGestureIDBadge setDelegate:self];
[btn_Barcode_IDBadgeView addGestureRecognizer:longpressGestureIDBadge];
[longpressGestureIDBadge release];

Advertisements
 
Leave a comment

Posted by on April 23, 2012 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: