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];


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s